Page 1 of 1

working with forms

Posted: Mon Jul 26, 2004 8:17 pm
by Pizmal
Question. I am buidling a website with php and mysql. I have a question about putting information into a form. I can push data back into a form from mysqk if its a text box or a textarea..... However how to do pre-select a value for a radio button or a drown down box.

<input type=radio SELECTED value=foobar>Foo

is the html to preselect (i think) a value. But how to I do this with php and mysql without a hught IF statement with 6 options?

From
Pizmal

Posted: Mon Jul 26, 2004 8:29 pm
by jtc970
I ussually do something like this

$cmember = what I want selected and I have all the coices in an array

Code: Select all

foreach($names as $name){
		$memberbox .= "<option value='$name'";
		if($name==$cmember){$memberbox.= " selected";}
		$memberbox .=">$name</option>\n";
	}

Posted: Mon Jul 26, 2004 8:31 pm
by Pizmal
:)


Thank you....

From
Pizmal