Hi,
I have a problem updating a table in MySQL.
I'm selecting a specific record to update. the code below outputs the results to screen.
<?php
$query=mysql_query ("SELECT job_no, staff_no, service_id, airline_id, Flight_no, seat_no, place_met_pax, place_left_pax, status, desk_no, Completed_by FROM job where date = sysdate() and job_no = '$job_no'");
while ($row =@ mysql_fetch_array($query)) {
$job_no = $row['job_no'];
$staffnumber = $row['staff_no'];
$service = $row['service_id'];
$airline=$row['airline_id'];
$flightnumber=$row['Flight_no'];
$seatnumber=$row['seat_no'];
$placemet=$row['place_met_pax'];
$placeleft=$row['place_left_pax'];
$status=$row['status'];
$desknumber=$row['desk_no'];
$completedby=$row['completed_by'];
?>
<tr><td>Job Number</td><td><?php echo "$job_no"?> </td></tr>
<tr><td>Staff Number</td><td>
<input name="staff_no" type="number" value="<?php echo "$staffnumber"?>"> </td></tr>
<tr><td>Service</td><td>
<input name="service_id" type="text" value="<?php echo "$service"?>"> </td></tr>
<tr><td>Airline</td><td>
<input name="airline_id" type="text" value="<?php echo "$airline"?>"> </td></tr>
<tr><td>Flight Number</td><td>
<input name="Flight_no" type="number" value="<?php echo "$flightnumber"?>"> </td></tr>
<tr><td>Seat Number</td><td>
<input name="seat_so" type="text" value="<?php echo "$seatnumber"?>"> </td></tr>
<tr><td>Place to Meet</td><td>
<input name="place_met_pax" type="text" value="<?php echo "$placemet"?>"> </td></tr>
<tr><td>Place Passenger Left</td><td>
<input name="place_left_pax" type="text" value="<?php echo "$placeleft"?>"> </td></tr>
<tr><td>Status</td><td>
<input name="status" type="text" value="<?php echo "$status"?>"> </td></tr>
<tr><td>Desk Number</td><td>
<input name="desk_no" type="text" value="<?php echo "$desknumber"?>"> </td></tr>
<tr><td>Completed By</td><td>
<input name="completed_by" type="number" value="<?php echo "$completedby"?>"> </td></tr>
<?php
}
?>
<input name="add_button" type="submit" value="Click To Save">
<input type="reset" name="Reset" value="Reset"></p>
</form>
Once the relevant changes have been made, i select the submit button.
The code below is supposed to be performing the update.
<?php
session_start();
//get connection to database
$db_host = "localhost";
$db_name = "OCS";
$db_username = "";
$db_password = "";
$connection = @mysql_pconnect($db_host, $db_username, $db_password) or
die("Unable to make connection to database server $db_host");
@mysql_select_db($db_name, $connection) or
die("Unable to find database $db_name");
$job_no=$_GET['job_no'];
$staffnumber=$_GET['staff_no'];
$service=$_GET['service_id'];
$airline=$_GET['airline_id'];
$flightnumber=$_GET['Flight_no'];
$seatnumber=$_GET['seat_no'];
$placemet=$_GET['place_met_pax'];
$placeleft=$_GET['place_left_pax'];
$status=$_GET['status'];
$desknumber=$_GET['desk_no'];
$completedby=$_GET['Completed_by'];
$query = "update job set staff_no = '$staffnumber', service_id = '$service', airline_id = '$airline', Flight_no ='$flightnumber', seat_no = '$seatnumber', place_met_pax = '$placemet', place_left_pax = '$placeleft', status = '$status', desk_no = '$desknumber', Completed_by ='$completedby' where job_no = '$job_no'";
@mysql_query($query,$connection) or die ("Unable to perform query.<br>$query");
header('Location: open_jobs.php');
?>
Does anyone have any ideas of why it doesn't update the database??
Thanks
I have a problem updating a table in MySQL.
I'm selecting a specific record to update. the code below outputs the results to screen.
<?php
$query=mysql_query ("SELECT job_no, staff_no, service_id, airline_id, Flight_no, seat_no, place_met_pax, place_left_pax, status, desk_no, Completed_by FROM job where date = sysdate() and job_no = '$job_no'");
while ($row =@ mysql_fetch_array($query)) {
$job_no = $row['job_no'];
$staffnumber = $row['staff_no'];
$service = $row['service_id'];
$airline=$row['airline_id'];
$flightnumber=$row['Flight_no'];
$seatnumber=$row['seat_no'];
$placemet=$row['place_met_pax'];
$placeleft=$row['place_left_pax'];
$status=$row['status'];
$desknumber=$row['desk_no'];
$completedby=$row['completed_by'];
?>
<tr><td>Job Number</td><td><?php echo "$job_no"?> </td></tr>
<tr><td>Staff Number</td><td>
<input name="staff_no" type="number" value="<?php echo "$staffnumber"?>"> </td></tr>
<tr><td>Service</td><td>
<input name="service_id" type="text" value="<?php echo "$service"?>"> </td></tr>
<tr><td>Airline</td><td>
<input name="airline_id" type="text" value="<?php echo "$airline"?>"> </td></tr>
<tr><td>Flight Number</td><td>
<input name="Flight_no" type="number" value="<?php echo "$flightnumber"?>"> </td></tr>
<tr><td>Seat Number</td><td>
<input name="seat_so" type="text" value="<?php echo "$seatnumber"?>"> </td></tr>
<tr><td>Place to Meet</td><td>
<input name="place_met_pax" type="text" value="<?php echo "$placemet"?>"> </td></tr>
<tr><td>Place Passenger Left</td><td>
<input name="place_left_pax" type="text" value="<?php echo "$placeleft"?>"> </td></tr>
<tr><td>Status</td><td>
<input name="status" type="text" value="<?php echo "$status"?>"> </td></tr>
<tr><td>Desk Number</td><td>
<input name="desk_no" type="text" value="<?php echo "$desknumber"?>"> </td></tr>
<tr><td>Completed By</td><td>
<input name="completed_by" type="number" value="<?php echo "$completedby"?>"> </td></tr>
<?php
}
?>
<input name="add_button" type="submit" value="Click To Save">
<input type="reset" name="Reset" value="Reset"></p>
</form>
Once the relevant changes have been made, i select the submit button.
The code below is supposed to be performing the update.
<?php
session_start();
//get connection to database
$db_host = "localhost";
$db_name = "OCS";
$db_username = "";
$db_password = "";
$connection = @mysql_pconnect($db_host, $db_username, $db_password) or
die("Unable to make connection to database server $db_host");
@mysql_select_db($db_name, $connection) or
die("Unable to find database $db_name");
$job_no=$_GET['job_no'];
$staffnumber=$_GET['staff_no'];
$service=$_GET['service_id'];
$airline=$_GET['airline_id'];
$flightnumber=$_GET['Flight_no'];
$seatnumber=$_GET['seat_no'];
$placemet=$_GET['place_met_pax'];
$placeleft=$_GET['place_left_pax'];
$status=$_GET['status'];
$desknumber=$_GET['desk_no'];
$completedby=$_GET['Completed_by'];
$query = "update job set staff_no = '$staffnumber', service_id = '$service', airline_id = '$airline', Flight_no ='$flightnumber', seat_no = '$seatnumber', place_met_pax = '$placemet', place_left_pax = '$placeleft', status = '$status', desk_no = '$desknumber', Completed_by ='$completedby' where job_no = '$job_no'";
@mysql_query($query,$connection) or die ("Unable to perform query.<br>$query");
header('Location: open_jobs.php');
?>
Does anyone have any ideas of why it doesn't update the database??
Thanks