Thought I had fixed this long ago, but I guess not. What I am trying to do should be simple, but my simple mind isn’t figuring it out.
What I want to do is search the database for an expired value ($expiredate) and then change another variable.
I have tried if SELECT where $expiredate < $todaydate, I have tried IF statements, to no avail.
I am here:
require_once ('connect.php');
$todaydate = $_SERVER['REQUEST_TIME'];
$db = mysqli_connect($db_hostname,$db_username,$db_password,"ptb_members") or die ("Cannot Connect to database");
$result = mysqli_query($db,"SELECT * FROM test WHERE active = 'y' AND exempt = 'n'") or die ("Cannot select from db");
while ($row = mysqli_fetch_array($result)) {
extract($row);
if ($expiredate < $todaydate){
$query = "UPDATE test SET active='n' WHERE (id = '$id')";
$result = mysqli_query($db,$query) or die("<b>Fatal Error: (" . mysqli_errno() . ") " . mysqli_error());
echo "User $fname $lname ($id) active status changed to n<br>";
}
But it only changes the first one and no more.
Why doesn’t SELECT * Where expiredate < $todaydate work?
Why cant I UPDATE active=‘n’ WHERE $expiredate < $todaydate?
I know there is a better way, but haven’t figured it it yet. Needs smarter minds than mine.
Thanx