I am new on php and I have create a project that bring a data from the database as the user selection , and when the execution of the project it occurred an error at an method , and I didn't now how to solve it . hear is the php code : -
<?php
$db = new PDO('sqlite:dinner.db');
$meals = array('breakfast','lunch','dinner');
if(in_array( $_POST['meal'], $meals)){
$stmt = $db->prepare('SELECT dish,price FROM meals WHERE meal LIKE ?');
$stmt->execute(array($_POST['meal']));
$rows = $stmt->fetchAll();
if(count($rows) == 0){
print "No dishes available now";
} else {
print "<table><tr><th>dish</th><th>price</th></tr>";
foreach($rows as $row) {
print "<tr><td>$row[0]</td><td>$row[1]</td></tr>";
}
print "</table>";
}
} else {
print "Unknown meal";
}
?>
and that is the html page code :
<html>
<head>
</head>
<body>
<form method="post" action="test.php">
<lable>Select the meal to see all the available dishes:
<input type="text" name="meal">
</lable><input type="submit" value="Ok">
</form>
</body>
</html>
and that is the output at the browser: - enter image description here