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
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 " ";	
}
}

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.