hey guys,,could you help me bout my problem? I want to make a function and i want to preselect its ID's not its values,,

this is my code

function getVisibility(){
echo "<option id=0>Inactive</option>
<option id=1>Active</option>
<option id=2>Active on Website</option>
<option id=3>active on churchwide calendar</option>";

}

I want to pass the ids to update my table in the database and the value should be 0,1,2,3 not the active,inactive........

$evisibility=$_POST;

sql="Update weeklyevent SET visibility=$evisibility where weid=$weid";

Recommended Answers

All 3 Replies

Member Avatar for Rkeast

I don't fully understand what you are trying to accomplish...

Are you trying to use PHP to generate a form based off of data you pull from a table in a database?

Member Avatar for diafol

Shouldn't this be:

function getVisibility(){
echo "<option value='0'>Inactive</option>
<option value ='1'>Active</option> 
<option value ='2'>Active on Website</option>
<option value ='3'>active on churchwide calendar</option>";
}

The $_POST array will now store the option 'value' attribute (in the select 'name'/'id' $_POST key).

$array = $_POST;
foreach($array as $values => $value) {
	//echo $value.'<br />';
	$value = trim($value);
//Everything except the "sumbit" button
		if($value != "Submit") { 
	$result = mysql_query("INSERT INTO `table` (`field`) VALUES ('$value')", $connection);

			}
	

}

This is something i Use to get values for multiple checkboxes, and then i query them into the Db! of course you can do whatever you want with them!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.