#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    145
    Rep Power
    15
    Can some please help me. I have a section of a web site that is for downloads of photography. There are seven different subject to view and I have these subjects and the corresponding URL's where their photos are stored in a mySQL database.

    I have no problems using the database to tell me how many photos are in the database, how many by subject, and even there names. I have been able to call them up and display them with no problems.

    The problem I do have is I want to generate a table, 6 columns wide (736 pixel width as well) and have php add the photos to it - generating new rows of the table on the fly with the found set of photos it pulls from the database. I just do not know how to format the code to put in my while statements that when it fetchs all the rows in the found set to insert them into the cool table that I need.

    My database name is Tphotos and the table is photos. I have defined the following fields as well - subject, photoname, alttext, lowressource, highressource.

    I pull the low res in first with alt tect and the link to the highres and open it in a different window.

    Can someone help me with the code to draw a table on the fly? Like I need above... That would be very cool.

    Thank you all and this is what makes PHP so cool.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    Here's a simplified version of a two cell repeatin row table. Note that you should do some error checking to make sure that you have a result before you try to count the number of rows. You can also use mysql_fetch_array and go through the array for count($result_array).
    <?
    $result = mysql_query("select * from photos",$myconnection);
    ?>
    <table width=100%>
    <?
    for ($i = 0; $i < mysql_num_rows($result); $i++)
    {
    ?>
    <tr>
    <td>
    <?echo mssql_result($result,$i,"photo_name");
    </td>
    <td>
    <img src="<?echo mysql_result($result,$i,"image_path");?>">
    </td>
    </tr>
    <?
    }
    ?>
    </table>

    ------------------
    ----------------------
    Ulysses J Ludwig
    Consultant
    Ujludwig@yahoo.com
    213.948.8278

Similar Threads

  1. php/mysql problem creating tables
    By riley in forum PHP Development
    Replies: 3
    Last Post: February 10th, 2004, 05:13 AM
  2. php/mysql search multiple tables
    By Seilo in forum PHP Development
    Replies: 3
    Last Post: January 21st, 2004, 05:40 PM
  3. tables get corrupted
    By 90coders in forum MySQL Help
    Replies: 1
    Last Post: December 5th, 2003, 05:23 AM
  4. Using PHP/MySQL Tables To Build Sites...
    By madcat in forum PHP Development
    Replies: 2
    Last Post: October 2nd, 2003, 01:26 PM
  5. complex search probs (mult tables php/mysql)
    By ajax in forum MySQL Help
    Replies: 1
    Last Post: September 17th, 2003, 06:37 PM

IMN logo majestic logo threadwatch logo seochat tools logo