Basically I am trying to make it check if the user has their ID in the database and if they do have it in there it updates it putting $page as 'lastpage' in the database. It also checks to make sure that the value it has set inside there now is less than $page, if it isn't than it does nothing.
If the user doesn't have there ID in there than it should add it with whatever $page is set to.
The problem is that it isn't updating in the database at all.
This is the code I got so far, anyone got ideas?
session_start();
if(!isset($_SESSION['id'])) {
header("Location: ../../index.php");
} else {
}
include '../../connect.php';
include '../../users_func.php';
$id = $_SESSION['id'];
$page = 3;
$sql_chk = " select * from html where id = '$id' and lastpage = '$page' ";
$rs_chk = mysql_query($sql_chk);
$num_chk = mysql_num_rows($rs_chk);
if ($num_chk == 0) {
mysql_query("INSERT INTO `html` (`id`, `lastpage`) VALUES ('$id', '$page') ");
} else {
$sql = "UPDATE html SET lastpage='$page' WHERE id='$id' and lastpage < $page";
mysql_query($sql) or die("MYSQL Query Failed : " . mysql_error());
}