-1

I have a car database which stores several cars for each individual model, I am trying to retrieve all the cars for a specific model however my code is not working, where am I going wrong?

$ModelID = $_GET['model_id'];

$result = mysqli_query($con, "SELECT * FROM Car WHERE ModelID = $ModelID");

while($row = mysql_fetch_assoc($result))
{           
   echo $row["RegNumber"];
   echo $row["Colour"]; 
}

1 Answers1

0

I think you are having error here

while($row = mysql_fetch_assoc($result))
{           
   echo $row["RegNumber"];
   echo $row["Colour"]; 
}

you should use mysqli_fetch_assoc($result) instead.

Do not mix the functions of mysql & mysqli API if your code is previously written in mysql api try to port it to mysqli or PDO.

Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45