Jump to content

while loop


techker

Recommended Posts

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

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

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

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.