I have this code
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
$rName = $row['abb'];
echo $row['name'];
?>
<html>
<select id="<?php echo $rName;?>">
<option value="Yes">Enabled</option>
<option value="No">Disabled</option>
</select>
<?php
echo '<br>';
}
echo '<br>';
echo '<input type="submit" name="submit"/>';
echo '</form>';
So as you can see, Everytime I have a new $row['name']
its going to create a new selector with the name of $row['abb']
How do I do the update the table priv and put the value from that selector into the row with the same name as the selector..
For instance, if I had two $row['name']
it would create two $row['abb']
One would be named op2, the other would be named op3
In my priv table I have rows op2-op24 . So How could I do this so it know to update the correct row with that value?
UPDATE 1**
I tried this
if(isset($_POST['submit'])){
$userIDi = $user['ident'];
$op2 = $_POST['op2'];
$op3 = $_POST['op3'];
$op4 = $_POST['op4'];
$op5 = $_POST['op5'];
$op6 = $_POST['op6'];
$op7 = $_POST['op7'];
$op8 = $_POST['op8'];
$op9 = $_POST['op9'];
$op10 = $_POST['op10'];
$op11 = $_POST['op11'];
$op12 = $_POST['op12'];
$op13 = $_POST['op13'];
$stmt=$con->prepare("UPDATE priv SET op2 = $op2, op3 = $op3, op4 = $op4, op5 = $op5,
op6 = $op6, op7 = $op7, op8 = $op8, op9 = $op9, op10 = $op10, op11 = $op11, op12 = $op12, op13 = $op13 WHERE ident = :ID");
$stmt->bindparam(":ID", $userIDi);
$stmt->execute();
Doing that gave me this error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' op4 = , op5 = , op6 = , op7 = , op8 = , op9 = , op10 = , op11 = , op12 = , op' at line 1' in /nfs/c11/h05/mnt//html/orderpage.php:204 Stack trace: #0 /nfs/c11/h05/mnt/2080/html/orderpage.php(204): PDOStatement->execute() #1 {main} thrown in /nfs/c11/h05//html/orderpage.php on line 204