Help in updating values in database using PHP?

Claudette

New member
So the code is assigning a truck per location. But inside the database, only one type truck is stored for all locations. Please help


<?php
include ("database_connection.php");
connect();

$i = 0;
$result1 = mysql_query("SELECT * FROM `customer_information` ci join `customer_order` co WHERE ci.Customer_Number= co.Customer_Number AND co.Customer_Number = co.Customer_Number");
$count = mysql_num_rows($result1);
if ($count != 0)
while($row1 = mysql_fetch_array($result1)){
$i++;
$order_no = $row1['Order_Number'];
$cust_no = $row1['Customer_Number'];
$receipt_no = $row1['Receipt_Number'];
$date_ordered = $row1['Date_Ordered'];
$exp_date = $row1['Expected_Date'];
$location = $row1['Location'];



if ($location == 'place1' || $location == 'place2' || $location == 'place3')
{
$truck = "truck1";

} else if ($location == 'place4' || $location == 'place5' || $location == 'Caloocan' || $location == 'place7')
{
$truck = "truck2";
}else if ($location == 'place8' || $location == 'place9')
{
$truck = "truck3";

}

mysql_query("UPDATE customer_order set `Truck` = '$truck' where Location = '$location'");



}

?>
I used echo to see if the code really assigns a truck per location. It does. In the php page, the right truck is printed together with the location. The problem is really in the database since it does only store one truck for all locations.
 
Back
Top