My two DB arrays:
ORDER --> (id, customer_id)
CUSTOMER --> (id, name)
They have foreign key(order.customer_id and customer.id).
I have an html form with a textfield and submit button, that user gives the name of the customer and i want to take from a query, the orders of the selected customer. This is my code, I have an error in SELECT statement. If anyone can help...
<?php
$connect = mysql_connect("localhost", "root", "") or die("Unable to connect to MySQL");
$selected = mysql_select_db("eshop", $connect) or die("Could not select examples");
if (isset($_POST['name'])) {
$customerName = $_POST['name'];
}
$result = mysql_query("SELECT order.id
FROM order, customer
WHERE order.customer_id = customer.id
AND customer.name = $customerName
");
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysql_fetch_array($result))
{
echo $row['order.id'];
}
mysql_close($connect);
?>