FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » php filling in listbox value based on db record ??
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
php filling in listbox value based on db record ?? [message #169399] Thu, 09 September 2010 13:21 Go to previous message
PAkerly is currently offline  PAkerly
Messages: 7
Registered: September 2010
Karma:
Junior Member
I've got an html page that fills in text boxes based on an sql
record. Doing things like this:

$sql = "SELECT date, user1, user2, user3, id
FROM myuserdata
WHERE id= '$txtid'
ORDER BY id";

//Get a result set from the query (this is the array)
$rs = mysql_query($sql) or die(mysql_error() . "<br />Sql:" . $sql);

//Declare an empty array to store the result set in
$array = array();

//Iterate through the result set we declared earlier, looping through
each row
while($row = mysql_fetch_array($rs, MYSQL_ASSOC))
{
//Append the row from the database, onto the array :)
$array[] = $row;
}

and then to fill in text boxes based on the previously selected ID I
do...
foreach($array as $row):

<input name="txtdate" type="text" id="txtdate" value="<?php echo
$row['date'];?>"/>

SO NOW I WANT TO ALSO SELECT A DEFAULT VALUE FOR A LISTBOX BASED ON
THE ID....

<select name="lstuser2" id="lstuser2">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>

So lets say that the record for this user called for the listbox to be
set to C b/c thats whats in the DB for this person, how could I do
this based on the record?

thanks.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Eregi possible problem
Next Topic: My head is spinning
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 11:40:03 GMT 2024

Total time taken to generate the page: 0.03998 seconds