Re: [PHP4BETA] Problem with script

From: Date: Tue, 04 Apr 2000 23:16:53 +0000
Subject: Re: [PHP4BETA] Problem with script
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-13125@lists.php.net to get a copy of this message
Thanks for the help everyone. Chris and Chris your solution worked brilliantly. Unfortunately, Judd, the code you gave me didn't build an array (?). So, I couldn't call the proper column to use. Anyhow, thanks EVERYONE for your help. Works great now, and I learned a bit. =) Cheers, Bradley ----- Original Message ----- From: Chris King <chrisk@dobetterdeals.com> To: Bradley <mccroreyb@linux.com> Sent: Wednesday, April 05, 2000 12:22 AM Subject: Re: [PHP4BETA] Problem with script > Did you figure out whats wrong already? If not here ya go, I didn't see > it on the list. > > Everytime you call mysql_fetch_row it will increment. Change the code > to > > while ($row = mysql_fetch_row($result)){ > echo "<OPTION VALUE=\"$row[1]\">$row[1]"; > } > > Happy coding! > > Bradley wrote: > > > Hello, I'm using PHP4 on an online inventory system that I'm building > > in-house. I've only just started working, and I've already run into a > > problem. It is entirely possible that this is a newbie problem, as I'm > > very new to database work. Anyhow, here goes. I'm building a select > > box from a select query on a table. The script looks like > > this: <html> <head> > > <title>Online Inventory System: Hardware Query Builder</title> > > </head> > > <body bgcolor="white"> > > <?php $db = mysql_connect("---servername---", "---username---", > > "---password---"); > > mysql_select_db("gu_mgmt",$db); > > $result = mysql_query("SELECT * FROM SubCat",$db); > > ?> > > Select the sub-category for your query from the given values:<br><br> > > <FORM ACTION="gu3.php" METHOD="post"> > > <select name="subcats"> > > <option value="All"">All > > <?php > > while (mysql_fetch_row($result)){ > > $row = mysql_fetch_row($result); > > echo "<OPTION VALUE=\"$row[1]\">$row[1]"; > > } > > ?> > > <INPUT TYPE="submit" name="RunQuery" VALUE="Run > > Query"> > > </select> > > </form> > > </body> > > </html> It's a pretty simple script, which is why I can't understand > > what's going on. There are 30 rows in the SubCat table, but the script > > only returns 15 options. Very strange. The returned html looks like > > this. <html> <head> > > <title>Grand United Online Inventory System: Hardware Query > > Builder</title> > > </head> > > <body bgcolor="white"> > > Select the sub-category for your query from the given values:<br><br> > > <FORM ACTION="gu3.php" METHOD="post"> > > <select name="subcats"> > > <option value="All"">All > > <OPTION VALUE="Desktops">Desktops<OPTION > > VALUE="Printer">Printer<OPTION VALUE="PABX">PABX<OPTION > > VALUE="S/Sheets">S/Sheets<OPTION VALUE="Print Server">Print > > Server<OPTION VALUE="File Server">File Server<OPTION > > VALUE="Backup">Backup<OPTION VALUE="Word Processing">Word > > Processing<OPTION VALUE="File Transfer">File Transfer<OPTION > > VALUE="Graphics/design">Graphics/design<OPTION VALUE="Operating > > System">Operating System<OPTION > > VALUE="Equipment">Equipment<OPTION > > VALUE="Photocopier">Photocopier<OPTION VALUE="Exel > > Templates">Exel > > Templates<INPUT TYPE="submit" name="RunQuery" VALUE="Run > > Query"> > > </select> > > </form> > > </body> > > </html> Any help is appreciated. Cheers,Bradley >

« previous php.version4 (#13125) next »