Your code looks good though. But Try the following approach –
$current_date = $_POST['current_date'];
$current_date = date( 'Y-m-d', strtotime($current_date) );
$post_id = (int) $_POST['post_id'];
$query = $wpdb->prepare( "SELECT start_date FROM {$wpdb->prefix}booking_history WHERE start_date=%s AND post_id=%d", $current_date, $post_id );
/* get_col used to retrieve column records */
$results = $wpdb->get_col( $query );
echo '<pre>'; print_r( $results ); echo '</pre>';
Related Posts:
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Should I use Transients with W3 Total Cache APC Caching? [closed]
- Add indexing to meta_value in wp_postmeta
- Get posts by menu ID
- Slow SQL_CALC_FOUND_ROWS Query
- What is an efficient way to query based on post_meta?
- WP_Query Performance Issues with meta_query
- Should close $wpdb via $wpdb->close()
- Get the post permalink within the loop but without additional DB query
- Filter WordPress posts by between parameter
- Retrieve featured image (thumbnail) url from multiple posts with one query
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- What’s faster? One big query, or several smaller ones?
- How WordPress attaches its Featured Images with posts?
- Order by custom table and multiplication
- why update and delete query not worked in custom table?
- How to implement a new row_count method in WordPress?
- querying data via $wpdb and get_row
- wp_Qwery works to slow
- Show all data in database table and make it into an interactive table
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- database query with more than a couple meta hangs and doesn’t complete
- How to access custom WordPress database tables
- Is it possible to query from external database? [duplicate]
- WP User Query with Custom Fields and Search Results
- List of ways to access WordPress database?
- Specify strict ‘order by’ in WordPress query
- How to set up hierarchical relationships without using plugins / meta query
- how to get Nearby zipcode
- Does WordPress have something like Drupal’s DB API?
- Using Transients
- Slow Query On Search
- how to write wordpress query for multiple metakeys checking?
- Wpdb->query result show 1 but is not an integer
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- Storing an array of objects related to each user
- Retrieve data from wordpress db via input and put those result in dropdown
- WP Query – filtering terms with regex
- WP_Query with page_ids in arguments without a result
- Function to retrieve IDs of posts, cache results, and improve wp_query
- Why last row deleted when refresh page
- Query a database based on form input then output to another page [closed]
- wp query search multi terms
- How to get meta key list efficiently?
- How to get user avatar via WPDB
- How to extend WP_query to a specific table?
- Fix wp_term_relationships slow query in get_posts
- Translating WP query into to SQL query
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- WP_Term_Query->get_terms() very slow query for WordPress filter
- Separate by Category Post Type
- I removed the “wp_rm_logs” table and am constantly getting this error
- Track write actions to the database
- Include post_status check within $wpdb query
- wpdb get_results() returns only 2 rows
- Website goes slow down after importing long database
- WP_Query always returning the last custom post
- option select form always deleting the sql query
- Optimising amount of calls to custom fields
- 294 Queries on Mainpage of WordPress
- how to add limit records in wordpress query
- Custom WP_query in Jnews theme returns thousands of posts
- WP_Query by meta key not returning any posts
- SQL query into to WP query
- Tracing the life of a query
- Query all posts where meta value is empty
- How to get post meta value and post in one query?
- wp query by search in titles only & put the posts in loop
- Woocommerce custom loop to show all the products [closed]
- Pagination 404 errors for author posts query on author.php
- List the 5 most recent child pages
- Meta-value query
- WP_Query compare with dynamic values
- WP Rest API max limit include parameter?
- Adding multiple post queries with parent and children to page – Best Way
- Programmatically set ‘meta_query’ for filter
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- WP_Query create html structure
- How is WP_Query parsed to determine which template to request?
- new WP_Query(), have_posts() return false in user_register hook
- Include current post into loop
- Is it safe to access the underlying mysqli object from \wpdb for custom queries?
- Loop 3 posts column wise and continue the loop into same columns
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- WP_Query custom order and pagination
- WordPress WP_Query compare not working?
- Excluded category from loop
- Add content depending on page loaded
- Custom template for password protected page
- How to get all user posts from two post types in wp_query
- meta_query with meta values as serialize arrays
- pre_get_posts pagination not working
- wp_set_object_terms() custom taxonomy not working correctly when using insert post
- Is my code correct?
- wp_query returns match with no criteria
- How can I modify standard search query to include also ACF custom fields values?
- Order WP_Query results in order other than ASC or DESC
- More efficient query to display posts in same sub-category?
- How to write a query-function as a query-shortcode?