PHP CODE
<?php
$num = 2020-10-21;
$num = $_POST['subject'];
echo $num;
global $wpdb;
$results = $wpdb->$results = $wpdb->get_results("SELECT * FROM wpsk_youtube_programs WHERE rating_date = . $num . ");
foreach ($results as $key => $program) { ?>
HTML CODE
<form name="form" action="" method="post">
<input type="date" name="subject" id="subject" value="<?php echo date('2020-10-21'); ?>" />
<input type="submit" />
</form>
here I am doing that get the date from the input field and store it on a variable ($num)
and now I want to pass this variable in the condition where I was fetching data from the data base so every time when anybody select a date and click on submit button so he can able to see the record of that day (from database)
My Answer:
global $wpdb;
$min_value = 10;
$max_value = 20;
$query = $wpdb->prepare("SELECT * FROM wp_posts WHERE post_date BETWEEN %d AND %d", $min_value, $max_value);
$results = $wpdb->get_results($query);
Rate this post
5 of 5 based on 8801 votesComments