RE: [PHP] Printing MySQL into HTML Tables

From: Date: Thu, 22 Mar 2001 22:36:51 +0000
Subject: RE: [PHP] Printing MySQL into HTML Tables
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7706@lists.php.net to get a copy of this message
Hello, Using it myself to... Maybe this will help you out: <!--BEGIN TABLE BORDER--> <table width='90%' align='left' border='1'><tr><td> <!--BEGIN TABLE DATA--> <table width='90%' align='left'> <tr><td colspan='2'align='left'> <font color='#FFFFFF' face='Verdana' size='2'><b>blabla a headline here </b></font></td></tr> <tr> <!-- first <tr> for table with data --> <?php require ('dbconnect_includefile_with_passwd.inc'); $i=1; //this sets the counter to 1 $naam_nl = "%"; $result = mysql_query ("your query goes here to retrieve the data"); if ($row = mysql_fetch_array($result)) { do { echo "<td width='50%'>" . $row["1"] . "</td>"; $i++; //the counter loops trough the do()while() and prints records if ($i==3) { echo "</tr><tr>"; //when the counter reaches 3 it prints the row-end and new beginning. //don't forget to code the <tr> for the first row outside of the php-code $i=1; //sets the counter to one again and the loop starts all over } } while ($row = mysql_fetch_array($result)); } else {print ("Sorry, no record were found.");} ?> </tr></table> <!--END TABLE DATA--> </td></tr></table> <!--END TABLE BORDER--> Hope thsi will help. Regards, Bart -----Oorspronkelijk bericht----- Van: Jeff Oien [mailto:jeff@webdesigns1.com] Verzonden: donderdag 22 maart 2001 22:19 Aan: PHP Onderwerp: [PHP] Printing MySQL into HTML Tables I would like to do this with a MySQL database containing product information: <tr><td>Product 1 Info</td><td>Product 2 Info</td></tr> <tr><td>Product 3 Info</td><td>&nbsp;</td></tr> And if there are an odd number of products I want it to complete the table row with nothing in the cell. I want it to be able to automatically do this no matter how many products there are. I'm not sure how to set it up to print every other like that. Jeff Oien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#7706) next »