Note that there are some explanatory texts on larger screens.

plurals
  1. POphoto not displaying after making php call
    primarykey
    data
    text
    <p>I am trying to retrieve some data from a database using php, then I add the data inside json_encode array to be sent to my other php file so that the contents could be displayed on a site. currently I am able to retrieve contents that contain text however, I am unable to retrieve the images. For example instead of displaying an image of London, the text London..jpg is displayed. </p> <p>Here is my php file that selects the data for the data base</p> <pre><code> &lt;?php require_once('conn.inc.php'); $stmt = $mysqli-&gt;prepare("SELECT CityName,CityID, CityPopulation,CitySkills,CityEmploymentRates,CityjsaClaimants ,Image ,CityWeeklyEarnings FROM citiesdata WHERE CityID = ? ORDER BY CityName"); $stmt-&gt;bind_param('i', $_GET['CityID']); $stmt-&gt;execute(); $stmt-&gt;bind_result($CityName, $CityID,$CityPopulation,$CitySkills,$CityEmploymentRates,$CityjsaClaimants,$Image,$CityWeeklyEarnings); $myArray = array(); while ($stmt-&gt;fetch()) { $myArray[] = $CityName; $myArray[] = $CityPopulation; $myArray[] = $CitySkills; $myArray[] = $CityEmploymentRates; $myArray[] = $CityjsaClaimants; $myArray[] = $Image; $myArray[] = $CityWeeklyEarnings; } echo json_encode($myArray); ?&gt; </code></pre> <p>And here is the javascript code I am using to retrieve the data in to my website, I am retrieving the data using CityID for example if CityID is 1 a radio button is clicked with value 1 this will match the CityID of 1 which is London and the details of the city will be displayed except the image since I have multiple images I have used json_encode I have no idea where to put the image src since I am working with multiple cities with multiple images. Everything is displayed fine on the website the cityName,Cityskills etc when the user selects a city via a radio button, how can I make it so that when the user selects the radio button the city images will be displayed alongside the cityNames, city skills etc?</p> <pre><code>$(document).ready(function(){ $('input[name=CityID]').on('click', function(){ var sendVals = $(this).serialize(); var returnData = ""; $("#displayResults").html('&lt;li&gt;Please Wait!&lt;/li&gt;'); $.get("phpCalling.php", sendVals, function(myData){ $.each(myData, function(key, value) { returnData += "&lt;p&gt;" returnData += value; returnData += "&lt;/p&gt;"; }) $("#displayResults").html(returnData); }, "json"); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload