I am hoping that someone can help me with this relative simple problem:
<?php $idairports = the_ID(); ?>
$liveposts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM wp_airports WHERE id = ".$idairports."") );
It seems like I am not able to get the variable passed into the sting above.
$idairports is supposed to be a numeric value…
If I do this <?php echo $idairports ?> I do get the value.
But I do not get the value here FROM wp_airports WHERE id = ".$idairports.""
What am I doing wrong
Thanks
Okay I have found the main problem:
global $wpdb;
$page_object = $wp_query->get_queried_object();
$page_id = $wp_query->get_queried_object_id();
$idairports = $page_id;
It seems like I were getting the_ID(); value the wrong way…
If I get the page_id as above, it works 100%
Can someone maybe explain why the_ID() would work if I echo the_ID() outside the MYSQL statement…
Your quotes are screwed up and your php tags look awkward: