Hello guys I'm new to web development and I'm currently working on my personal project where my classmates will be able to log in to the website and see there grades, etc.
But problem I'm having at the moment is that when I echo out the values (that I got from mysql table) with function mysqli_fetch_array, it works fine but when I try to echo values in html tabel, only the last one is shown. I'm trying to get all the grades from first semester into one cell. I'm looking for solution for quite a while.
Php code:
$host = "localhost";
$username = "root";
$password = "";
$db = "r1b";
$potrdilo = "";
$povezava = mysqli_connect($host, $username, $password, $db) or die("Napaka pri povezavi");
$uporabnisko = $_SESSION['uporab'];
$geslo = $_SESSION['gesl'];
$sql = "select ime, priimek from uporabniki where email = '".$uporabnisko."' and geslo = '".$geslo."' limit 1";
$pregled = mysqli_query($povezava, $sql);
$vrstica = mysqli_fetch_array($pregled);
$ime = $vrstica['ime'];
$priimek = $vrstica['priimek'];
$ocene_matematika = "select prvo_polletje from ocene where id = '".$ime."' and predmet = 'Matematika' limit 2";
$pregled_ocene = mysqli_query($povezava, $ocene_matematika);
$matematika = array();
while($ocena = mysqli_fetch_array($pregled_ocene)){
$matematika = $ocena['prvo_polletje'];
}
?>
<html>
<head>
</head>
<body>
<table border = "solid 1px black">
<tr>
<td>Predmet</td>
<td>Prvo polletje</td>
<td>Drugo polletje</td>
<td>Povprecje prvega polletja</td>
<td>Povprecje drugega polletja</td>
<td>Koncna ocena</td>
</tr>
<tr>
<td>Matematika</td>
<td><?php $matematika?></td>
</tr>
</table>
</body>
</html>
------------------------------------------------------------------------
If you need anymore information just ask for It and I'll post it.
PS. Sorry for bad english trying my best
</div>
i guess, you are not looping through your array. mysqli_fetch_array returns array, so you have to loop through the array like the following.
<tr><?php
while($row = mysqli_fetch_array($result)) {
"<td>". $row['column1'];."</td>"
"<td>". $row['column2'];."</td>"
"<td>". $row['column3'];."</td>"
}
?>
</tr>