Hi
I have a function which either updates or inserts a record into the database table, depending on what the user selects.
However I need to manually refresh the page after the action has been done, as the status is not updating on the page.
How can I force a refresh of the page directly after either the UPDATE or INSERT has been done?
Many thanks for the help
///// functions /////
function update_shortlist($prop_id,$user_id,$new_status)
{
$prop_id = (Int)$prop_id;
$user_id = (Int)$user_id;
// Connect to the database
$dbc = mysqli_connect("localhost", "xxxxxxxxx", "xxxxxxxxx", "xxxxxxxx");
// Check to see if the item is already on the short list
$query_chkStatus = "SELECT status FROM DEV_property_shortlist WHERE DEV_property_shortlist.prop_id=$prop_id AND DEV_property_shortlist.ID = $user_id";
$chkStatus = mysqli_query($dbc, $query_chkStatus) or die(mysql_error());
$chkRows = mysqli_num_rows($chkStatus);
if ($chkRows > 0) {
// Update Existing Row
$query = "UPDATE `DEV_property_shortlist` SET status= '$new_status', `add_date` = Now() WHERE DEV_property_shortlist.prop_id=$prop_id AND DEV_property_shortlist.ID = $user_id";
mysqli_query($dbc, $query) or die(mysql_error());
}
else {
if ($new_status = 'Shortlisted') {
// Insert New Row
$query = "INSERT INTO `DEV_property_shortlist`(`prop_id`, `ID`, `status`, `add_date`) VALUES ($prop_id,$user_id,'Shortlisted',Now())";
mysqli_query($dbc, $query) or die(mysql_error());
}
}
mysqli_close($dbc);
}
?>