I´m new to this board and php, but i allways read it for answers when i get stuck in php.
Anyhow, I have this problem wich i´ve been trying to solve for the last week without any succes.
I made this script that compares 2 dates to each other to output the sum of those two into a column in a mysql database.
$row[6] = registrered date.
$row[7] = registrered date + 10 days.
$row[9] = remaining days
When i run the code below i get this output:
Name: name1
Before Update: 0
Patch Status: UPDATE `table` SET status=10
After Update: 5
Name: name2
Before Update: 0
Patch Status: UPDATE `table` SET status=10
After Update: 5
Name: name3
Before Update: 0
Patch Status: UPDATE `table` SET status=5
After Update: 5
Everything seems fine except putting the correct values in $row[9].
I hope you php gurus can help me with this one.
I can´t seem to find an answer anywhere in my php books nor php forums.
Thank you for your time & sorry about the length of this thread.
/Owe Blomqvist
Here´s the code.
Code: Select all
<?
$link = mysql_connect ("host", "user", "pass");
$database = mysql_select_db ("database");
$sql = "SELECT * FROM table";
$result = mysql_query($sql);
for($i=0; $i <=$result; $i++)
{
$row = mysql_fetch_row($result);
$difference = ($rowї'7'] - $rowї'6']);
$sum = ($difference - ($difference % 86400)) / 86400;
$patch_status = "UPDATE `table` SET status=$sum";
$do_patch = (mysql_query($patch_status));
if(!$do_patch)
{
echo "Hmmm. No workie";
return false;
}
mysql_query($do_patch);
echo "Name: $rowї1]<br>
Before Update: $rowї9]<br>
Patch Status: $patch_status<br>
After Update: $rowї9]<br><br>";
}
?>