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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.