Forum Moderators: coopster

Message Too Old, No Replies

Pulling Data from MySQl dbase.

         

tonynoriega

10:59 pm on May 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i pull data from mysql database, and show it in the form fields for my agents to modify and update...

the one thing i cant get right is how to pull the data if the field option was a radio button, drop down list, or checkbox....

also i cant seem to get the remarks section to pull either...
the remarks field is set to "TEXT" in the database....

currently i am using
value="<? echo "$remarks"?>

to pull data into the text fields....

anyone got a tip on this?

jatar_k

1:29 am on May 25, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> how to pull the data if the field option was a radio button, drop down list, or checkbox

that would depend on how you're saving it. Test for a yes or on or whatever and echo checked or whatever you need to in the appropriate form element.

If the other field is saved in a TEXT field then you would think it should be a textarea, just a guess though.

tonynoriega

9:13 pm on May 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, so i got the drop down lists to pull from the dbase properly.... if they select 4 in the drop down list, on the modify page, it says 4 when they request that record.

What i can not get now is the radio buttons.

i am storing them as VARCHAR in my dbase, either a YES or NO....

how can i pull those values from the table, and have them check the appropriate radio button based on the value?

IndiaMaster

7:35 am on May 26, 2007 (gmt 0)

10+ Year Member



You should check the value first and I assume it is stored in a variable called $var then you may try the following piece of code:
<?php
if($var=="Yes")
{
echo("<input type=radio value=Yes checked>Yes");
echo("<input type=radio value=No>No");
}
else
{
echo("<input type=radio value=Yes>Yes");
echo("<input type=radio value=No checked>No");

}
?>

I think it should work, but I am also in search of a better solution, as it will create problem in handling large number of values for $var.