Jump to content

how to display 3 clickable images in a row from database


Recommended Posts

I want to display 3 clickable images in a single row which repeats as long as there is data in the database, so far it is displaying a single clickable image from the database. below is all the code..

 

  <table width="362" border="0">

         

        <?php   

$sql=mysql_query("select * from `publication` GROUP BY `catsue`") or die(mysql_error());

$num=mysql_num_rows($sql);

 

while($rowfor=mysql_fetch_array($sql))

{

 

 

$cat=$rowfor['catsue'];

$pic=mysql_query("select * from `category` where `catsue`='$cat'") or die(mysql_error());

$picP=mysql_fetch_array($pic);

$base=basename($picP['title']);

?>

<tr>

              <td width="352" height="88"><table width="408" border="0">

                <tr>

                  <td width="113" rowspan="5"><a href="archive_detail.php?id=<?php echo $rowfor['id'];?>&category=<?php echo $rowfor['catsue'];?>"><img src="ad/pic/<?php echo $base;?>" width="100" height="100" border="0"/></a></td>

                  <td width="94">Title</td>

                  <td width="179" height="1"><?php echo $rowfor['catsue'];?> </td>

                </tr>

                <tr>

                  <td> </td>

                  <td width="179" height="3"> </td>

                </tr>

                <tr>

                  <td> </td>

                  <td width="179" height="8"> </td>

                </tr>

                <tr>

                  <td> </td>

                  <td width="179" height="17"> </td>

                </tr>

                <tr>

                  <td> </td>

                  <td width="179" height="36"> </td>

                </tr>

              </table></td>

              </tr>

              <?php

 

}?>

         

          </table>

Are you always going to display only three or do you mean an unknown number of pictures in a three column layout?

If it's the last one you need a counter for how many pictures you already displayed plus a last line to be padded if you run out of pictures.

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.