techker Posted March 6, 2011 Share Posted March 6, 2011 Hey guys i have a blog with images on the side.im doing a script that i can change the images and links to.. i cant seem to figure out how to echo link to image1.. echo (linked_image(table row)'== 'img1') echo (linked_image(table row)'== 'img2') echo (linked_image(table row)'== 'img3').... <? $recent_req2 = "SELECT * FROM $table_m LIMIT 4 , 4"; $res2 = mysql_query($recent_req2); do {?> <div> <a href="<?php echo $link('linked_image'== 'img1');?>"><img src="tmp/1_180x100_v2.gif" alt="" width="180" height="100" /></a> <a href="<?php echo $link['img2']; ?>"><img src="tmp/2_180x100_v2.gif" alt="" width="180" height="100" /></a> <a href="<?php echo $link['img3']; ?>"><img src="tmp/3_180x100_v3.gif" alt="" width="180" height="100" /></a> <a href="<?php echo $link['img4']; ?>"><img src="tmp/4_180x100_v5.gif" alt="" width="180" height="100" /></a> </div> <? } while ($link = mysql_fetch_array($res2)); ?> Link to comment https://forums.phpfreaks.com/topic/229773-while-loop/ Share on other sites More sharing options...
Simmo Posted March 6, 2011 Share Posted March 6, 2011 Not sure exactly what you mean but I would be doing it like this: assuming you have a field in the table called img <?php recent_req2 = "SELECT * FROM $table_m LIMIT 4 "; $res2 = mysql_query($recent_req2); while($img=mysql_fetch_array($res2)){ ?> <a href="img/<?php echo $link['img']; ?>"><img src="img/<?php echo $link['img']; ?>" alt="" width="180" height="100" /></a> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/229773-while-loop/#findComment-1183570 Share on other sites More sharing options...
techker Posted March 6, 2011 Author Share Posted March 6, 2011 well i have a table called link in it i have link_ID linked _IMG and Link so i have 4 pre determed images the querry quets the link table so img 1 in database it is img1 image 2 is img2... (need link in DB)<a href="<?php echo $link('linked_IMG'== 'img1');?>">(image)<img src="tmp/1_180x100_v2.gif" alt="" width="180" height="100" /> </a> <a href="<?php echo $link('linked_IMG'== 'img2');?>">(image)<img src="tmp/1_180x100_v2.gif" alt="" width="180" height="100" />.... Link to comment https://forums.phpfreaks.com/topic/229773-while-loop/#findComment-1183573 Share on other sites More sharing options...
fenway Posted March 7, 2011 Share Posted March 7, 2011 Where's the mysql question? Link to comment https://forums.phpfreaks.com/topic/229773-while-loop/#findComment-1184031 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.