Jump to content

Display images from mysql and php


fanding

Recommended Posts

Hi

I am trying to output images on my pages from my mysql DB and I have the below mysql and php code. My problem is the images display fine but I also has extra 3 image placeholders.

 

Can any one help? I have php 5 and mysql 5

 

 

function PagImgs($show = 1) {
$url = db('website');
$id = ($_GET['id']);

$query = "SELECT * FROM mrc_pages_pag WHERE id_pag = {$id} AND visible_pag = 1 AND img_show_pag = 1 ORDER BY ordering_pag DESC LIMIT 1";

if ($result = mysql_query($query)) {

echo '<div id="PageImgHolder">';
do{

$image1 = $r['img1'];
$image2 = $r['img2'];
$image3 = $r['img3'];

echo '<img src="'.$url.'images/'.$image1.'" " border="0" align="top" /><p>';
echo '<img src="'.$url.'images/'.$image2.'" " border="0" align="top" /><p>';
echo '<img src="'.$url.'images/'.$image3.'" " border="0" align="top" />';

} while ($r = mysql_fetch_array($result));

echo '</div>';
}else {

echo "";	
}
}

Link to comment
https://forums.phpfreaks.com/topic/79945-display-images-from-mysql-and-php/
Share on other sites

I have doen it this way and it seem to work fine, any other ideas?

 

Thanks

 

function PagImgs($show = 1) {
$url = db('website');
$id = ($_GET['id']);

$query = "SELECT * FROM pages WHERE id = {$id} AND visible = 1 AND show = 1 ORDER BY ordering DESC LIMIT 1";

if ($result = mysql_query($query)) {

echo '<div id="PageImgHolder">';

while ($r = mysql_fetch_array($result)) {
echo '<img src="'.$url.'images/'.$r['img1'].'" " border="0" align="top" /><p>';
echo '<img src="'.$url.'images/'.$r['img2'].'" " border="0" align="top" /><p>';
echo '<img src="'.$url.'images/'.$r['img3'].'" " border="0" align="top" />';
echo '</div>';
}
}
else {

echo " ";	
}
}

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.