I made a poll webpage, for taking a poll in the classroom, students should go around and ask everyone the question or questions.
Just a little technical point: I have an INSERT and UPDATE variable:
$mysql = 'INSERT INTO poll_1_data(surveyornr, weeknr, gender, choice) VALUES (?, ?, ?, ?)';
$mystmt = $pdo->prepare($mysql);
$mystmt->execute([$surveyornr, $weeknr, $q1, $q2]);
Then, a bit further down I have:
$mysql = 'UPDATE poll_count20BECW SET ' . $weeknr . ' = ' . $weeknr . ' + 1 WHERE studentnr = ' . $surveyornr;
//echo 'SQL is ' . $mysql . '<br>';
$mystmt = $pdo->query($mysql);
I think the $mystmt is “burned” after use in the first INSERT sql, so I just re-declare $mysql as UPDATE
Is this bad practice?
Should I call the second one $mysql2 and $mystmt2?
(I also have a third statement in this PHP file to UPDATE the table poll_totals.)