0

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

2

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.