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
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
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
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.