shadiadiph Posted December 25, 2008 Share Posted December 25, 2008 I have a usertable which has a field timeslogged so how do i write it so that each time this is activated it updated has 1 added to it.? $DB_site->query("UPDATE tbluserdetails set logged= 'Y', dtlogged='now()', timeslogged='????' where username='$username'"); Also is there anyway to reset the value of a field every 24 hours automatically? Quote Link to comment https://forums.phpfreaks.com/topic/138371-solved-adding-1-to-a-value-each-time-something-happens/ Share on other sites More sharing options...
PravinS Posted December 25, 2008 Share Posted December 25, 2008 Try this $DB_site->query("UPDATE tbluserdetails set logged= 'Y', dtlogged='now()', timeslogged = timeslogged + 1 where username='$username'"); Quote Link to comment https://forums.phpfreaks.com/topic/138371-solved-adding-1-to-a-value-each-time-something-happens/#findComment-723527 Share on other sites More sharing options...
shadiadiph Posted December 25, 2008 Author Share Posted December 25, 2008 cool thanks that works perfectly is there anyway of using a timestamp in the capacity that resets the value to the originl value after 24 hours? Quote Link to comment https://forums.phpfreaks.com/topic/138371-solved-adding-1-to-a-value-each-time-something-happens/#findComment-723554 Share on other sites More sharing options...
shadiadiph Posted December 27, 2008 Author Share Posted December 27, 2008 mm this script isn't actually working if their is apictur it still displays it but if there isn't it wont display anything in the else { section when i view the page directly showpic it gives me the error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/hmtcompa/public_html/user/showpic3.php on line 6 if their is no image won't show anything even something simple. <?php require("../global/admin_functions.php"); $query = "SELECT thumbnail4,thumbnailtype4 FROM zloads where intProductID=".$_GET['adid']; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { $data = mysql_result($result,0,"thumbnail4"); $type = mysql_result($result,0,"thumbnailtype4"); Header( "Content-type: $type"); print $data; } else { print hello; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138371-solved-adding-1-to-a-value-each-time-something-happens/#findComment-724297 Share on other sites More sharing options...
shadiadiph Posted December 27, 2008 Author Share Posted December 27, 2008 sorry silly me I posted this on the wrong post. Quote Link to comment https://forums.phpfreaks.com/topic/138371-solved-adding-1-to-a-value-each-time-something-happens/#findComment-724315 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.