Hi,
I have designed a simple competition which contain 3 tables, one of these tables is for the questions..
in this code I have managed to retrieve question no. 1 from the database, and I can changed it through this form and press change to send the data to the table.
Everything works fine up to now.. but I want to make it works for all the questions in my table, so I can change them all in one page.. I think there should be a way to do it by loop rather than retyping the whole code again for each question.
At the same time it would be very helpful if I can make it both for questions and answers.. in other words I can change the question and the answer and press one button to update the database table..
Any help?
<?php
require ("connect.php");
if (isset($_POST['submit']) && isset($_POST['tochange1'])) {
$tochange1 = $_POST['tochange1'];
$changeQ1 = mysql_query("UPDATE questions SET Question='" . mysql_real_escape_string($tochange1) . "' WHERE QuestionNO = 1");
}
$resultQ1 = mysql_query("SELECT question FROM questions WHERE QuestionNO=1");
while ($row1 = mysql_fetch_assoc($resultQ1)) {
echo $row1["question"];
}
echo "
<form method='POST'>
<input type='text' name='tochange1' />
<input type='submit' name='submit' value='Change' />
</form>
<br />
";
?>