JohnMac328
asked on
PHP - Display image based on record id
I am working with an example and trying to change it up some. This code lists the records in the table. I am trying to add the image associated with each record in the list of all the records. Here is the list of records
Here is the code that dispalys the image based on the record id - I can't get the syntax to work with the previous code that is listing the records
<img src="<?php echo $row['s_img']; ?>" width="102" height="111"/>
Thanks
<?php
if($result = $mysqli->query($query)){
$no = 1;
while($row = $result->fetch_assoc()){
echo "<tr>
<td>$no</td>
<td><a href='student_info.php?s_id=".$row['s_id']."'>".$row['name']."</a></td>
<td>".$row['class']."</td>
</tr>"
;
$no++;
}
}
?>
Here is the code that dispalys the image based on the record id - I can't get the syntax to work with the previous code that is listing the records
<img src="<?php echo $row['s_img']; ?>" width="102" height="111"/>
Thanks
ASKER
No that didn't work
Didn't work doesn't really tell me anything
How are the images named? Where are they in relation to the script?
How are the images named? Where are they in relation to the script?
ASKER
This code
<img src="<?php echo $row['s_img']; ?>" width="102" height="111"/>
works on another page that is displaying one record - I want it to display on the page that is just listing the records in the table - as the image shows it displays the records - how to add the image associated with the student?
example.jpg
<img src="<?php echo $row['s_img']; ?>" width="102" height="111"/>
works on another page that is displaying one record - I want it to display on the page that is just listing the records in the table - as the image shows it displays the records - how to add the image associated with the student?
example.jpg
Then it is probably the path that is incorrect, are the two php pages in the same folder?
ASKER
Yes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is what I needed - what you posted earlier
<img src="<?php echo $row['s_img']; ?>.jpg" width="102" height="111"/>
Did not work
Thanks
<img src="<?php echo $row['s_img']; ?>.jpg" width="102" height="111"/>
Did not work
Thanks
<img src="<?php echo $row['s_img']; ?>.jpg" width="102" height="111"/>