RE: [PHP] Newbie Question

From: Date: Mon, 02 Dec 2002 11:34:55 +0000
Subject: RE: [PHP] Newbie Question
Groups: php.general 
Request: Send a blank email to php-general+get-126701@lists.php.net to get a copy of this message
Hi Hacook, > I have a mySQL database called "srchresult" in a "srchresult" base. > In it, i have 9 fields. Everything works perfectly. > I would like to know how can i list in a HTML table 30 results for example > but only with 7 columns (7 fields only) ? Try this: <?php // open the db connection - replace these with your own settings $db = mysql_connect([server], [username], [password]); // select the database - replace with your own mysql_select_db([database], $db); // get the query - add your own field names here $q = mysql_query("SELECT Field1, Field2, Field3 FROM srchresult LIMIT 30"); // start the table echo "<table">; // loop through the results while ($r = mysql_fetch_array($q)) { // echo a table row ?> <tr> <td><?=$r["Field1"]?></td> <td><?=$r["Field2"]?></td> <td><?=$r["Field3"]?></td> </tr> <?php // end of while() loop } // finish the table echo "</table>"; ?> It's untested - shout if it doesn't work. Cheers Jon

« previous php.general (#126701) next »