-3

First time programming a simple database. But I cant figure out how to solve this error:

Parse error: syntax error, unexpected '$row' (T_VARIABLE) in W:...\index.php on line 39

This is my script..

$result = mysqli_query($link,"SELECT * FROM studenten");

echo "<table border='1'>

<tr>
<th>first name</th>
<th>last name</th>
<th>studentnummer</th>
</tr>";

while($row = mysqli_fetch_array($result)) {

  id = $row[id]; //this is line 39
  echo "<tr>";
  echo "<td>" . $row['voornaam'] . "</td>";
  echo "<td>" . $row['studentnummer'] . "</td>";
  echo "<td> <a href ='edit.php?id_student=$id'>Edit</a>";
  echo "<td> <a href ='delete.php?id_student=$id'><center>Delete</center></a>";
  echo "</tr>";
}                     

echo "</table>";

can someone help me?

PHP Worm...
  • 4,109
  • 1
  • 25
  • 48

2 Answers2

1
id = $row[id]; //this is line 39

Shouldn't that be

$id = $row['id']; //this is line 39

You're missing the $ from your id variable and quotes for your array key.

Ankh
  • 5,478
  • 3
  • 36
  • 40
1

use

mysqli_fetch_assoc

because

mysqli_fetch_array  

returns a indexed array

and on line 39

$id = $row['id']; 
PHP Worm...
  • 4,109
  • 1
  • 25
  • 48