fanding Posted December 3, 2007 Share Posted December 3, 2007 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 ""; } } Quote Link to comment Share on other sites More sharing options...
fanding Posted December 3, 2007 Author Share Posted December 3, 2007 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 " "; } } Quote Link to comment Share on other sites More sharing options...
fenway Posted December 3, 2007 Share Posted December 3, 2007 Extra? What do you mean? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.