RE: [PHP-DB] RE: [PHP] Printing MySQL into HTML Tables

From: Date: Fri, 23 Mar 2001 11:29:59 +0000
Subject: RE: [PHP-DB] RE: [PHP] Printing MySQL into HTML Tables
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7715@lists.php.net to get a copy of this message
Or try this one, its simple but more universal and very usefull for eg. testing. ... and a bit mor structured >8)=) <?php function result_all( $sql_result ) { echo "<TABLE>\n"; $columns = mysql_num_fields( $sql_result ); for ( $i = 0; $i < $columns; $i++ ) { echo " <TH> ".mysql_field_name( $sql_result, $i )." </TH>\n"; } while ( $row = mysql_fetch_row( $sql_result ) ) { echo " <TR>\n"; for ( $count = 0; $count < $columns; ++$count ) echo " <TD> ".$row[$count]." </TD>\n"; } echo " </TR>\n"; } echo "</TABLE>\n"; } ?> Greetinx, Mike Michael Rudel - Web-Development, Systemadministration - _______________________________________________________________ Suchtreffer AG Bleicherstraße 20 D-78467 Konstanz Germany fon: +49-(0)7531-89207-17 fax: +49-(0)7531-89207-13 e-mail: mailto:mru@suchtreffer.de internet: http://www.suchtreffer.de _______________________________________________________________ > -----Original Message----- > From: Bart A. Verbeek [mailto:b.a.verbeek@wanadoo.nl] > Sent: Thursday, March 22, 2001 11:37 PM > To: PHP-DB mailinglist; jeff@webdesigns1.com > Subject: [PHP-DB] RE: [PHP] Printing MySQL into HTML Tables > > > 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 > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.db (#7715) next »