June 27th, 2000, 12:05 PM
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.
June 27th, 2000, 02:27 PM
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);
for ($i = 0; $i < mysql_num_rows($result); $i++)
<img src="<?echo mysql_result($result,$i,"image_path");?>">
Ulysses J Ludwig