Thanks Amrit, worked a treat! Sorry jon, your's looks good too, I just read Amrit's post first! Thanks anyway,
Matt >-----Original Message----- >From: Amrit Hallan [mailto:amrit@;amrithallan.com] >Sent: 18 October 2002 03:53 >To: [EMAIL PROTECTED] >Subject: [wdvltalk] Re: [PHP] listing database values... > > >Do you want this? > > ><?php > >$result=mysql_query($query); >$num_fields=mysql_num_fields($result); >echo "<table border=1><tr>"; >for($i=0; $i<$num_fields; $i++) >{ > echo "<th>"; > echo mysql_field_name($result, $i); > echo "</th>"; >} >echo "</tr>"; >while($row=mysql_fetch_row($result)) >{ > echo "<tr>"; > for($i=0; $i<$num_fields; $i++) > { > echo "<td>"; > if(!isset($row[$i])) > { > echo "NULL"; > } > else > { > echo $row[$i]; > } > echo "</td>"; > } > echo "</tr>"; >} >echo "</table>"; >?> > >Amrit Hallan >������������������������������������������������������ >Web Site Development - http://www.bytesworth.com >Copywriting and Copy Editing - http://www.amrithallan.com >������������������������������������������������������ >WebDevE-Publication: [EMAIL PROTECTED] > > > >----- Original Message ----- >From: "Macdonald-Wallace, Matthew J" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Thursday, October 17, 2002 10:31 PM >Subject: [wdvltalk] [PHP] listing database values... > > >> All, >> >> I'm trying to write a page in PHP that will list all the >values in a given >> table when it is selected. >> >> Is there an easy way of doing this? >> >> The code I'm using at the moment is below. This selects >the correct table, >> but will not echo the values. Any help is much >appreciated... >> >> TIA, >> >> Matt >> >> =.=.=.=.=.=.=.=.=.=.=.=.=.=.= >> >> <?include("library/database.php");?> >> <form action="test.php" method="post"> >> <? >> echo "<select name=\"tablename\">"; >> $result = mysql_list_tables(interact); >> >> if (!$result) { >> print "DB Error, could not list tables\n"; >> print 'MySQL Error: ' . mysql_error(); >> exit; >> } >> >> while ($row = mysql_fetch_row($result)) { >> print "<option >value=\"$row[0]\">$row[0]</option>\n"; >> } >> >> mysql_free_result($result); >> echo "</select><input type=\"submit\" value=\"Select\">"; >> ?> >> </form> >> <?php >> if($tablename!="") >> { >> $result = mysql_query("SELECT * FROM $tablename",$db); >> $i=0; >> while ($myrow = mysql_fetch_row($result)) { >> echo $myrow[i]; >> echo $i; >> $i++; >> } >> } >> ?> >> >> ____ . The WDVL Discussion List from WDVL.COM . ____ >> To Join wdvltalk, Send An Email To: >mailto:wdvltalk-join@;lists.wdvl.com >> Send Your Posts To: [EMAIL PROTECTED] >> To change subscription settings to the wdvltalk digest >version: >> http://wdvl.internet.com/WDVL/Forum/#sub >> >> ________________ http://www.wdvl.com >_______________________ >> >> You are currently subscribed to wdvltalk as: >[EMAIL PROTECTED] >> To unsubscribe send a blank email to >%%email.unsub%% >> > > >--- >Outgoing mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.401 / Virus Database: 226 - Release Date: >10/9/2002 > > >____ * The WDVL Discussion List from WDVL.COM * ____ >To Join wdvltalk, Send An Email To: >mailto:wdvltalk-join@;lists.wdvl.com > Send Your Posts >To: [EMAIL PROTECTED] >To change subscription settings to the wdvltalk digest version: > http://wdvl.internet.com/WDVL/Forum/#sub > >________________ http://www.wdvl.com _______________________ > >You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] >To unsubscribe send a blank email to >%%email.unsub%% > ____ � The WDVL Discussion List from WDVL.COM � ____ To Join wdvltalk, Send An Email To: mailto:wdvltalk-join@;lists.wdvl.com Send Your Posts To: [EMAIL PROTECTED] To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
