Jump to content

[SOLVED] display more than one image PHP


elviapw

Recommended Posts

I'm stumped-- I'm trying to display more than one image from a server via its url in a mysql database. the first image works fine, but the second two images just won't show up. I've checked the database and I know the image_url2 is there for the second image I want to display. here's the code:

 

<?php

$dbh = mysqli_connect("--", "--", "--", "--");


$sql = "SELECT Title,Content,Date, image_url FROM Posts ORDER BY id DESC";

$query = mysqli_query($dbh,$sql);

if($query) {

$rows = mysqli_num_rows($query);

for($i = 0; $i < $rows; $i++) { 

$feed = mysqli_fetch_array($query); 

$title = $feed['Title'];
$post = $feed['Content'];
$date = $feed['Date'];

$pic = $feed['image_url'];
$pic2 = $feed['image_url2'];
$pic3 = $feed['image_url3'];

echo "<tr >\n";
echo "<td >\n";
echo "<a href=\'archive.php'><font face='Georgia, Times New Roman, Times, serif' color='#999999'>$title</font></a>\n"; 
echo "<p>$date</p><br/>";
echo " <p>$post</p><br/>\n";

if ( !empty($feed['image_url']) ) {
echo "<img src= '$pic'/><br/><br/>";
} else {
echo " ";
}  

if ( !empty($feed['image_url2']) ) {
echo "<img src= '$pic2'/><br/><br/>";
} else {
echo " ";
} 

if ( !empty($feed['image_url3']) ) {
echo "<img src= '$pic3'/><br/><br/>";
} else {
echo " ";
} 


echo " <a href='delete.php'>delete this p0st</a>\n";
echo "<hr />\n";

echo "</td >\n";
echo "</tr>\n";

}
echo "</table>\n";
echo "</center>";
echo"<a style='text-decoration:none' href='/archive.php'><font color='#FF6600'><center>archive</center></font></a>";

} 

echo"</body>
</html>"

?>

Link to comment
https://forums.phpfreaks.com/topic/147501-solved-display-more-than-one-image-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.