I am not good with programming and english, and I’m 40++ .I have few questions about PHP PDO and Multi Select stuff..
I’ve created a multi select menu in a form, which invoke the value from database like this:-
<select multiple=multiple id="imsohot">
<?php
echo '<option value="$row[id]">';
?>
</select>
and It works fine.
I also created a new file to process the form to submit the data to database and it worked for normal database insertion, and it look something like this :-
$qry="query goes here";
stmt=conn->prepare($qry);
stmt->bindParam(1, $_POST['varname']);
stmt->execute();
My Question is:
But how do I submit values into database when it doesn’t have fixed array? like to submit the #imsohot multiselect menu when certain data is selected.
And regarding my question, which of these 2 links would solve my problem?
The answer is neither 🙂
To save your data to the database using PDO, you must first prime your SQL statement. This example of PDO::exec() shows what you’re trying to do.
Notice how it runs through PDO::prepare() and PDO::execute() using a while loop. All you need to do is use your form’s data where he passes $data in.
HTH 🙂