Reputation: 21
I already create an update sql statement, however if I echo the update sql, it shows that the values is updated, but when I check at the table, nothing have been change. Here is the update statement
$updatesql="UPDATE patient_surgery
set rn_no ='$rn_no',
ic_no = '$ic_no',
ot_location = '$ot_location',
ot_date = '$otdate',
ward = '$ward',
paying_status = '$paying_status',
class = '$class',
arrived_fr = '$arrived_fr',
discharge_to = '$discharge_to'
WHERE rn_no = '$rn_no'
and ot_date = '$otdate'";
if (mysql_query($updatesql))
{
echo "<p>successful</p>";
echo ($updatesql);
} else {
echo mysql_error();
}
and this is the print_r statement
UPDATE patient_surgery set rn_no ='RN001-13', ic_no = '771102016050', ot_location = '3', ot_date = '2014-02-12', ward = '01', paying_status = '2', class = '1', arrived_fr = '2', discharge_to = '3' WHERE rn_no = 'RN001-13' and ot_date = '2014-02-12'
and this is the value in the table after updating
" + Options Full texts Surg_Id rn_no ic_no ot_location ot_date ward paying_status class arrived_fr discharge_to Edit Edit Copy Copy Delete Delete rand52fad20d168f69.42722209 RN001-13 771102016050 2 2014-02-10 015 1 2 1 1"
Upvotes: 2
Views: 75
Reputation: 230
Your update query is based upon room no. and date. Date gets changed at the time of query submission and when WHERE clause looks for this current date, it doesn't find it and hence nothing happens. (Compare the ot_date
in your query and in your database)
First of all, you don't have any primary key
such as id. Your query should be based upon that id which remains unchanged and should not be displayed to update. Think if someone changes room no and date then how your WHERE clause is gonna find the matching record?
Upvotes: 2