mysql - Update the value in table row by id - PHP -


i trying increase number value in column called 'denda' every 24 hours followed different starting date. example if date reach current datetime start count 0.20 ..the next day should 0.40. value should different follow starting date in table.

this output

contohgambar

and code

$pulang = mysql_query("select id_peminjam, t_pinjam, t_pulang peminjaman status='lewat'"); $pulang2 = mysql_fetch_array($pulang); $id = $pulang2['id_peminjam']; $id2 = $pulang2['t_pinjam']; $id3 = $pulang2['t_pulang'];  "</br>"; date_default_timezone_set("asia/kuala_lumpur");  $now = time();  $your_date = strtotime($id3); $datediff = $now - $your_date; $bil_lewat= floor($datediff/(60*60*24));  $jum_denda = ($bil_lewat * 0.20);  $format = number_format($jum_denda, 2, '.', ''); 

i think can use mysql statement solve problem. add "datediff(curdate(),t_pulang)*0.2" sql statement calculate difference between dates. following, mysql 5.5 date , time functions - datediff, mysql now() function

mysql_query("select id_peminjam, t_pinjam, t_pulang, datediff(curdate(),t_pulang)*0.2 peminjaman status='lewat'"); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -