Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update problem

Status
Not open for further replies.

mcmon999

IS-IT--Management
Mar 3, 2005
21
GB
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"?>&nbsp;&nbsp;</td></tr>

<tr><td>Staff Number</td><td>
<input name="staff_no" type="number" value="<?php echo "$staffnumber"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Service</td><td>
<input name="service_id" type="text" value="<?php echo "$service"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Airline</td><td>
<input name="airline_id" type="text" value="<?php echo "$airline"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Flight Number</td><td>
<input name="Flight_no" type="number" value="<?php echo "$flightnumber"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Seat Number</td><td>
<input name="seat_so" type="text" value="<?php echo "$seatnumber"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Place to Meet</td><td>
<input name="place_met_pax" type="text" value="<?php echo "$placemet"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Place Passenger Left</td><td>
<input name="place_left_pax" type="text" value="<?php echo "$placeleft"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Status</td><td>
<input name="status" type="text" value="<?php echo "$status"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Desk Number</td><td>
<input name="desk_no" type="text" value="<?php echo "$desknumber"?>">&nbsp;&nbsp;</td></tr>

<tr><td>Completed By</td><td>
<input name="completed_by" type="number" value="<?php echo "$completedby"?>">&nbsp;&nbsp;</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
 
What does your '<form>' statement look like? It's not in the code you list.

Have you echoed your $query before trying the mysql_query? What does it contain?

Ken
 
Hi, thanks for replying!

the forms begins like:

<form name="Assign_job" action="update_job.php" method="GET">

Should i be declaring the mysql_query or doing something else with it??

sorry i'm new at this!!


 
try checking what is being passed by the form using

print_r($_POST)

u mug

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top