Featured post
php - Table cells flushed white -
upon running below sql statement (which works perfectly) i've found tables in database flushed white.
any idea why happening?
// check database necessary updates $update = mysql_query("select * rent colour='3c0'"); while($row_update = mysql_fetch_array( $update )) { $datetime_lower = datetime::createfromformat('d/m/y', $min); $datetime_upper = datetime::createfromformat('d/m/y', $max); $datetime_compare = datetime::createfromformat('d/m/y g:i a', $row_update['pdate']); if ($datetime_lower < $datetime_compare && $datetime_upper > $datetime_compare) { // date between nothing mysql_close($update); } else { // date not between update echo "date not between"; $update_result = mysql_query("update rent set colour='f0f0f0' substr(pdate, 0, 10) not between $min , $max && colour='3c0'"); mysql_close($update_result); } }
i've included few pictures.
this how meant (above code omitted):
http://i51.tinypic.com/143gpef.jpg
this how looks (above code present):
your while
loop appears go through results table. appears on each iteration of loop, check date first in php, check date again in update query, , update matching rows f0f0f0.
i don't know why code changing colour white instead of #f0f0f0, since there no white or fff in code, can suggest make code more efficient.
instead of updating rows on each iteration of while loop, if have id
column (primary key auto-increment) in rent
table, can use value in while loop instead of having test date second time.
$update = mysql_query("select * rent colour='3c0'"); while($row_update = mysql_fetch_array( $update )) { $datetime_lower = datetime::createfromformat('d/m/y', $min); $datetime_upper = datetime::createfromformat('d/m/y', $max); $datetime_compare = datetime::createfromformat('d/m/y g:i a', $row_update['pdate']); if ($datetime_lower < $datetime_compare && $datetime_upper > $datetime_compare) { // date between nothing mysql_close($update); } else { // date not between update echo "date not between"; $update_result = mysql_query("update rent set colour='f0f0f0' id=" . $row_update['id'] . " && colour='3c0'"); mysql_close($update_result); } }
- Get link
- X
- Other Apps
Comments
Post a Comment