how insert dropdown value in data base with php
please tell me sir
Assign a name
attribute to the select tag, a value
attribute to each option tag, set the method
to the submitting form and then read the matching array, for example, if you set the POST method, then you will have to read $_POST
, here's an example:
<form method="post" action="destination.php">
<select name="color">
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
</select>
<input type="submit" name="submit" value="submit" />
</form>
Now the receiving script (destination.php) can do:
<?php
if($_POST)
{
# check if $_POST['color'] is available
if(array_key_exists('color', $_POST))
{
# execute insert query here
echo $_POST['color'];
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.