RE: [PHP] stuck

From: Date: Fri, 17 Aug 2001 16:10:21 +0000
Subject: RE: [PHP] stuck
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63202@lists.php.net to get a copy of this message
You need to put the info in an array for all record to be available, like this: while ($row = mysql_fetch_array($result)) { $uid[] = $row['uid']; $address[] = $row['address']; $city[] = $row['city']; $state[] = $row['state']; $zip_code[] = $row['zip_code']; $country[] = $row['country']; $company[] = $row['company']; $occupation[] = $row['occupation']; $telephone[] = $row['telephone']; $fax[] = $row['fax']; and to get it out again, you need to use a for loop for ($i = 0; $i < count($uid); $i++) { echo $uid[$i]; ... } Hope this helps, Jan De Luyck > -----Original Message----- > From: Jeremy Morano [mailto:jeremy@prepresshelp.com] > Sent: Friday, August 17, 2001 6:05 PM > To: php-general@lists.php.net > Subject: [PHP] stuck > > > Hi, > > Can someone please tell me what is wrong with this page. The > problem is that > my option block is always stuck on the last record in the table. No matter > what option I choose, the information, address, city, state...etc, that is > passed is always the one of the last record in the table...Help! > > > > > > <? > session_start(); > session_register("address"); > session_register("city"); > session_register("state"); > session_register("zip_code"); > session_register("country"); > session_register("company"); > session_register("occupation"); > session_register("telephone"); > session_register("fax"); > > $db_name = "contact"; > $table_name = "company"; > > $connection = @mysql_connect("l", "c", "c") or > die("Couldn't connect."); > > $db = @mysql_select_db($db_name, $connection) or die("Couldn't select > database."); > > $sql = "SELECT * > FROM $table_name > "; > > $result = @mysql_query($sql,$connection) or die("Couldn't execute > query."); > > > while ($row = mysql_fetch_array($result)) { > $uid = $row['uid']; > $address = $row['address']; > $city = $row['city']; > $state = $row['state']; > $zip_code = $row['zip_code']; > $country = $row['country']; > $company = $row['company']; > $occupation = $row['occupation']; > $telephone = $row['telephone']; > $fax = $row['fax']; > > $option_block .= "<option value=\"$uid\">$company</option>"; > } > > > > $display_block = " > > <FORM METHOD=post ACTION=show_adduserbycompany.php> > > > <P><strong>Company:</strong> > <select name=\"uid\"> > $option_block > </select> > > <INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Select this > Company\"></P> > </form> > > "; > > ?> > > > <HTML> > <HEAD> > <TITLE>User Information: Add a User</TITLE> > </HEAD> > <BODY> > <h1> User Information</h1> > <h2><em>Add a User</em></h2> > <P>Select a company from the list below, to continue to the user > addition.</p> > > <? echo "$display_block"; ?> > > <p><a href="contact_menu.php">Return to Main Menu</a></p> > > </BODY> > </HTML> > > > -- > 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.general (#63202) next »