php - Where clause and Order By not returning as expected in WordPress -
i positive missing here.
i have mysql database table setup with: kdate, kday, kmonth, , kontent
kdate set expires date (admin input) formatted 01-01-2014 date(m-d-y)
i trying dates older today not show on execution of script.
global $wpdb; $today = date('m-d-y'); $result = $wpdb->get_results( "select * wp_kaltable kdate >= $today order kdate asc limit 6 "); //echo "<pre>"; print_r($result); echo "</pre>"; foreach($result $row) { echo "<div class='kalcontain'><div class='kal'><div class='kdate'><p class='kmonth'>".$row->kmonth."</p><p class='kday'>" .$row->kday."</div><div class='kontent'><p class='ktext'>".$row->kontent. "</p></div><div class'clear'></div></div></div>"; }
when execute script, data, ones dates less today's date. also, when using order by, ordering month , day, not year.
all assistance appreciated.
(*this code testing purposes only)
try instead:
"select * wp_kaltable kdate >= '$today' order kdate asc limit 6 "
the single quotes around $today important.
if kdate
date format utilize curdate() mysql don't have muck around in php:
"select * wp_kaltable kdate >= curdate() order kdate asc limit 6 "
if kdate not date format, may not since order isn't working correctly, neither of sql statements work. need convert date format in order >=
php mysql wordpress
No comments:
Post a Comment