I have a form where names from a SQL-database are listed. After each name there is a textfield for a grade. I want the grades and names to be saved in arrays. It already works with the names, but the array for the grades just gets filled with the content in the last textfield.
$Requete = "SELECT `vorname`, `nachname` FROM `lernende`";
$Result = mysql_query($Requete,$db);
$grade = array();
$vorname = array();
$nachname = array();
$counter = 0;
while($row = mysql_fetch_array($Result))
{
echo '<p>', $row["vorname"]," ", $row["nachname"], " ", '<label>Note: <input type="text" name="note"/></label></p>';
$grade[$counter] = $_POST['note'];
$vorname[$counter] = $row["vorname"];
$nachname[$counter] = $row["nachname"];
$counter = $counter + 1;
}
What is wrong with my code? I’ve just started learning php and have no idea how to solve this…
You hvae to change this line of code:
However, your code is not the finest I’d say. Start learning working with arrays as shown on http://php.net/array and start with clean HTML as described at http://de.selfhtml.org/ (since you are German speaking).