Answer the question
In order to leave comments, you need to log in
How to insert php variables into SQL query?
variable
$nowDate = current_time('Ymd', 0);
returns // 2017-07-21
how to insert $nowDate into query for date place 2017-07-20 to make it work
$userLists = $wpdb->get_results( 'SELECT user_name, user_bet, user_time FROM wp_konkurs WHERE `user_time` BETWEEN "2017-07-20 00:00:00" AND "2017-07-20 23:59:59" ORDER BY user_time DESC ');
Answer the question
In order to leave comments, you need to log in
For variables to work, they must either be written without quotes or in double quotes.
$a = 5;
echo $a; # 5
echo "$a"; # 5
echo '$a'; # $a
$userLists = $wpdb->get_results("SELECT `user_name`, `user_bet`, `user_time` FROM `wp_konkurs` WHERE `user_time` BETWEEN '$nowDate 00:00:00' AND '$nowDate 23:59:59' ORDER BY `user_time` DESC");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question