PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$user_name = $_SESSION['C_Name'];
$userID = $_SESSION['C_UserID'];
$sql2 = "SELECT MAX(ID) AS maxid FROM users_logins WHERE userid='$userID'";
$sql2_query = mysql_query($sql2) or die (mysql_error());
$ID_row = mysql_fetch_assoc($sql2_query);
$sql3 = "SELECT ID FROM users_logins WHERE userid='$userID'";
$sql3_query = mysql_query($sql3) or die (mysql_error());
$ID_num_rows = mysql_num_rows($sql3_query);
if ($ID_num_rows > 1) {
// $maxID = $ID_row['maxid'] - 1;
echo $maxID;
} else {
$maxID = $ID_row['maxid'];
}
I need to select in $maxID the previous number
Obvious i cant do "$maxID = $ID_row['maxid'] - 1" if i have values like 1,2,4,8,... the value selected become the number 7(8-1=7).
How can i do to select the number 4 in this example??