working with forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

working with forms

Post 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
jtc970
Forum Commoner
Posts: 38
Joined: Sun Jan 18, 2004 11:49 pm

Post 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";
	}
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

Post by Pizmal »

:)


Thank you....

From
Pizmal
Post Reply