I managed to fix my old error so I'm going to update this post with the new error. Basically I have to manually add a structure in phpmyadmin with my users ID in order for it to update using this code. Because I set it to update on whatever column has the same as the users id.
Any idea how I could do it differently so there is some sorta default automatically? I tried doing it so when you register it would do it and that works out well but I am going to have up to 10 different subjects so how would I do this in a more efficient way?
<?php
include 'connect.php';
include 'main.php';
$id = $_SESSION['id'];
$result3 = mysql_query("SELECT * FROM html WHERE id='$id'") or die("MYSQL Query Failed : " .mysql_error());
while($row3 = mysql_fetch_array($result3))
{
$lastpage=$row3['lastpage'];
}
$page = "page1.php";
$sql = "UPDATE html SET id='$id', lastpage='$page' WHERE id='$id'";
mysql_query($sql) or die("MYSQL Query Failed : " . mysql_error());
echo $lastpage;
?>
Another thing I'm trying to figure out is if I can make it check the database for the value under 'lastpage' like I did but then check if it is equal to page2 and above than it will not update the values at all. Basically it will only update the values if thats your first time going to the page on your account. Get it?
Anyone got any ideas?!
Do you think this would work?
<?php
include 'connect.php';
include 'main.php';
$id = $_SESSION['id'];
$result3 = mysql_query("SELECT * FROM html WHERE id='$id'") or die("MYSQL Query Failed : " . mysql_error());
while($row3 = mysql_fetch_array($result3))
{
$lastpage=$row3['lastpage'];
}
$page = "page1.php";
if(empty($lastpage)){
mysql_query("INSERT INTO `html`.`html` (`id`, `lastpage` VALUES ($id, $page");
} else {
$sql = "UPDATE html SET id='$id', lastpage='$page' WHERE id='$id'";
mysql_query($sql) or die("MYSQL Query Failed : " . mysql_error());
}
echo $lastpage;
?>