I have som problem writing back to table. I connect to table as wanted and get the information output correctly. The input correctedby, and the checkboxes is saving as i want. but i dont know how to write the mysql_fetch_assoc back to table I have this kode;
<?php
session_start();
$_SESSION['mypassword']="myusername";
echo "Logged in as:<br>" .$_SESSION['myusername'];
include "header.inc.php";
include "funksjoner.inc.php";
//in this file the connetion to server
$connection= kobleTil(); //trenger ikke oppgi databasenavn
//Steg 2: SQL-query
$sql = "SELECT * FROM oppgave WHERE modulid=1 AND resultat is NULL ORDER BY RAND() LIMIT 1";
$result = mysql_query($sql, $connection);
echo "<hr>";
while ($nextrow= mysql_fetch_assoc($result)){
echo "answer: " . $nextrow['answer'];
echo "<br>Modulid: " . $nextrow['modulid'];
echo "<br>student: " . $nextrow['studentid'];
echo "<br>";
}
echo '<form name="input" action="tilretting.php" method="get">';
echo'<input type="text" name="correctedby" value="'.$_SESSION['myusername'].'">';
echo 'Not approved<input type="checkbox" name="resultat" value="0">';
echo 'Approved<input type="checkbox" name="resultat" value="1">';
echo '<input type="text" name="studentid" value="dont know how to write correct here">';
echo '<input class="levermodulknapp" type="submit" name="lever1" value="Lever modul 1">';
echo "</form>";
echo "<hr>";
?>
how can I get the form to get the value from mysql_fetch_assoc into the form? Is the mysql_fetch_assoc the right thing to use? Very gratefull for any tip!
$result = mysql_query($sql, $connection);
echo "<hr>";
while ($nextrow= mysql_fetch_assoc($result)){
echo "answer: " . $nextrow['answer'];
echo "<br>Modulid: " . $nextrow['modulid'];
echo "<br>student: " . $nextrow['studentid'];
echo "<br>";
echo '<form name="input" action="tilretting.php" method="get">';
echo'<input type="text" name="correctedby" value="'.$_SESSION['myusername'].'">';
echo 'Not approved<input type="checkbox" name="resultat" value="0">';
echo 'Approved<input type="checkbox" name="resultat" value="1">';
echo '<input type="text" name="studentid" value="'.$nextrow['columnName'].'">';
echo '<input class="levermodulknapp" type="submit" name="lever1" value="Lever modul 1">';
echo "</form>";
echo "<hr>";
}
or
$data = null;
$result = mysql_query($sql, $connection);
echo "<hr>";
while ($nextrow= mysql_fetch_assoc($result)){
echo "answer: " . $nextrow['answer'];
echo "<br>Modulid: " . $nextrow['modulid'];
echo "<br>student: " . $nextrow['studentid'];
echo "<br>";
$data = $nextrow['colunmName'];
}
echo '<form name="input" action="tilretting.php" method="get">';
echo'<input type="text" name="correctedby" value="'.$_SESSION['myusername'].'">';
echo 'Not approved<input type="checkbox" name="resultat" value="0">';
echo 'Approved<input type="checkbox" name="resultat" value="1">';
echo '<input type="text" name="studentid" value="'.$data.'">';
echo '<input class="levermodulknapp" type="submit" name="lever1" value="Lever modul 1">';
echo "</form>";
echo "<hr>";
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.