I am new to PHP and Mysql programming and I would like to know if I can access another database row when showing data in a form.
Here is the code:
$mysql_host = "";
$mysql_database = "";
$mysql_user = "";
$mysql_password = "";
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database);
$result = mysqli_query($con, "SELECT * FROM Elev WHERE Clasa = '" . $_SESSION['clasa'] . "' ORDER BY Nume ASC ");
$result2 = mysqli_query($con, "SELECT * FROM M_Profesori WHERE ID = '" . $_SESSION['ID_p'] . "' ");
while ($row2 = mysqli_fetch_array($result2)) {
while ($row = mysqli_fetch_array($result)) {
echo "<select>
<option value='" . $row2["Materia"] . "'>" . $row2["Materia"] . "</option>
<option value='" . $row2["Materia"] . "'>" . $row2["Materia"] . "</option>
</select>";
}
}
In the second option (<option value='" . $row2[Materia] . "'>" . $row2[Materia] . "/option>) I would like to access the next database row, not this one. Is this possible?