0

I'm editing something like this:

<form action="" method="post">
    <select name="type">
        <option>Default</option>
        <option>Training Center</option>
    </select>
</form>

What I want to do is select the option I wanted and update that into a database column...

$db = ConnectionManager::getDataSource('default');

 $idselect = $db->query("SELECT max(id) FROM users");
$id = $db->query($idselect,'id');

$connect = $db->query("UPDATE users SET userType='".$_POST['type']."' Where id = '$id'");

But my problem is it still wont show in the database. Can anyone tell me what i'm doing wrong??

also the userType column I'm updating has a code like this

$userType = 'default';
Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48
Kobe1234
  • 33
  • 1
  • 5
  • Let's start with the HTML, your ` – Daan Jun 22 '16 at 08:28
  • http://stackoverflow.com/questions/22011735/insert-value-of-html-select-form-into-mysql-database –  Jun 22 '16 at 08:31
  • @Daan Value is optional not mandatory. So your comment doesn't provide a solution check this: [link](https://www.w3.org/wiki/HTML/Elements/option#HTML_Attributes) - value = string Provides a value for element. If there isn't, the value of an option element is the textContent of the element. – Osama Sayed Jun 22 '16 at 08:32
  • @OsamaSayed I know, I find it a bad habbit though. – Daan Jun 22 '16 at 08:33
  • @Daan Yeah it gets clearer when 'value' is present but just saying that It doesn't seem to be the problem. – Osama Sayed Jun 22 '16 at 08:34
  • Can you echo the value of `$_POST['type']`? – Osama Sayed Jun 22 '16 at 08:36

1 Answers1

0

You should use value attribute in select tag

 <select name="type">
    <option value="Default">Default</option>
    <option value="Training Center">Training Center</option>
</select>
Gopalakrishnan
  • 957
  • 8
  • 19