0

Trying to do a school project, essentially need to take the choice of animal from a dropdown menu, and add the ID of that animal to the order table of the database. dropdown is on a seperate page which works fine, and posts result to this page.

the code:

<?php

include_once("connect-db.php");

if(isset($_POST['Submit'])) {  

$choice = $_POST['choice'];

$result = mysqli_query($mysqli, "SELECT * FROM animals WHERE AnimalSpecies=$choice");

while($res = mysqli_fetch_array($result))

{

    $id = $res['AnimalID'];

}

$query = mysqli_query($mysqli, "INSERT INTO order('AnimalID') VALUES('$id')");

}

The connectdb file is fine, i have used it in another page. additionally, $choice is working fine, i had it echo manually and it shows the right value. I dont get any error message, it just doesnt add anything to the order table.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141

0 Answers0