Is there any way to create a prepared statement based on user selection?

46 views Asked by At

I know that the very definition of a prepared statement is that it's prepared, but is there any way to create a statement based on user selection?

For example, if there were a list of 10 groceries that the user could then select as they wished, and they selected 4 items. Is there a way to dynamically create a prepared statement based on that?

I've googled but haven't found anything that suits my needs.

$stmt = $bd->prepare("UPDATE member SET fname = ?, lname = ?, college = ?, address = ?, contact = ?, password = ? WHERE username = ?");
$stmt->bind_param("sssssss", $fname, $lname, $college, $address, $contact, $password, $username);
$stmt->execute();
$stmt->bind_result($username);
$stmt->fetch();

So this is what my prepared statements look like, and they work just fine, but I can't see a way to be able to put an unknown number of variables in. I am also in PHP 5.3, so mysqli_result etc are all out of the question.

0

There are 0 answers