[PHP] Re: holding values in a select list on a form
I worked it out by doing something like this... ? if (!$WR_COUNTRY ==) { $topic = $WR_COUNTRY; }; echo select name=\WR_COUNTRY\; $toplist = mysql_query(select * from wr_country where wr_country_enabled = 1 ); echo option value=\\Select/option\n; while(list($topicid, $topics) = mysql_fetch_row($toplist)) { if ($topicid==$topic) { $sel = selected ; } echo option $sel value=\$topicid\$topics/option\n; $sel = ; } ? Mark Bayfield [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Some help please... I am creating a select list from a database, and I am trying to hold the value of what has been selected by a user, while I do some error checking. It is searching a mysql db to pull out the list. It will then need to pass values back into the database. The code I am using is this... ? echo select name=\FIELDNAME\; print option value=\\Select/option; for ($index = 0; $index mysql_num_rows($query); $index++) { $row = mysql_fetch_row ($query) or die (mysql_error()); print option value=$row[1]$row[1]/option; } echo /select; ? If there is an easier way, let me know Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] RE: holding values in a select list on a form
? echo select name='FIELDNAME'; print option value=''Select/option; if($result = mysql_db_query($db, $query)) while($row = mysql_fetch_row($result)) print option value={$row[1]}{$row[1]}/option; echo /select; ? although personally I use mysql_fetch_array() so I can use the field name to get the appropriate field rather than getting the second field returned from the query (as you are doing). Tim Ward Senior Systems Engineer Please refer to the following disclaimer in respect of this message: http://www.stivesdirect.com/e-mail-disclaimer.html -Original Message- From: Mark Bayfield [mailto:[EMAIL PROTECTED]] Sent: 23 July 2001 10:34 To: [EMAIL PROTECTED] Subject: holding values in a select list on a form Some help please... I am creating a select list from a database, and I am trying to hold the value of what has been selected by a user, while I do some error checking. It is searching a mysql db to pull out the list. It will then need to pass values back into the database. The code I am using is this... ? echo select name=\FIELDNAME\; print option value=\\Select/option; for ($index = 0; $index mysql_num_rows($query); $index++) { $row = mysql_fetch_row ($query) or die (mysql_error()); print option value=$row[1]$row[1]/option; } echo /select; ? If there is an easier way, let me know Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]