Reputation: 1
i have one form in php, in this form have one select option
<select id="birdname" style="width: 150px; height: 25px; border-radius: 5px;">
<option>--Cambiar vendedor --</option>
<?php
$selectagent = "SELECT * FROM `" . $prefix . "user`";
$resultforagents = mysql_query($selectagent);
while ($agent = mysql_fetch_object($resultforagents)) {
?>
<option value="<?= $agent->user_id ?>" ><?= $agent->username ?></option>
<?php } ?>
</select>
<div id="stage" style="display:none;"></div>
Showing name of username, i need insert selected username (reference not name) into sql
<?php
$userId = $_POST['birdname'];
$idtill = $_SESSION['caj'];
$cashid = $_SESSION['cash'];
$mvalue = number_format($givenamount, 2, '.', '');
$mdate = date("Y-m-d H:i:s");
$moption = '1';
$sql = "INSERT INTO `" . DB_PREFIX . "order_user`(`user_id`, `order_Id`, `till`, `value`, `operation`, `comment`, `date`,`cashid`) VALUES ('" . $userId . "','" . $lastorderidis . "','" . $cashid . "','" . $mvalue . "','" . $moption . "', '" . " " . "', '" . $mdate . "','" . $cashid . "')";
$common->showresultsql($sql, 'update', 1);
echo $lastorderidis;
?>
Thanks
Upvotes: 0
Views: 259
Reputation: 4142
Add the name
tag to your select value to get the value of select like this:
<select id="birdname" name="birdname">
Now you will have the value by $_POST['birdname']
More info here: get the selected index value of <select> tag in php
Upvotes: 1