i have this script where i want it to demote anyone who hasnt logged in with the last 3 days to be demoted and it only to demote a certain rank down
this is my code
Thanks if anyone can help me fix this it will be good thanksPHP Code:require("dbconnect.php");
$gQuery="SELECT * FROM members";
echo $gQuery;
//excute the query
$rs=mysqli_query($con,$gQuery);
if(!$rs)
{
$dbError="Error:Failed to executing query".mysqli_error($con);
}
else
{
$count=$rs->num_rows;
if($count>0)
{
while($data=$rs->fetch_assoc())
{
$username=$data['username'];
$LastedLogin=$data['LastedLogin'];
$dsl= calcDSLCode($LastedLogin);
}
}
}
function calcDSLCode($LastedLogin)
{
$today=date("Ymd");
require("dbconnect.php");
$Query="SELECT TO_DAYS($today)-TO_DAYS($LastedLogin) FROM members";
echo $Query;
$result = mysqli_query($con,$Query);
if(!$result)
{
echo "Error:".mysqli_error($con);
}
else
{
$days = mysqli_fetch_array($result);
if($days>=3)
{
$gdQuery="Update Members set rank=rank-2 WHERE disable='1'";
echo "<br/><br/>".$gdQuery."";
$rs=mysqli_query($con,$gdQuery);
if(!$rs)
{
echo "Cannot demote $username because:".mysqli_error($con);
}
else
{
echo "People who have not Logged in with in 3 days will be demoted";
}
}
//
}
}





Bookmarks