Insert a database query into a post with post object
-
Hi all. I am trying to include a database query in my post_content through an external admin app that uses the post object. I tried this:
$my_post['post_content'] = $post_text . "<br /><php? $query = \"SELECT *, date_format(event_date, '%m/%d/%y') as new_date FROM events WHERE event_name='" . $event_name . "'\"; ?>" . $do_stuff_with_queried_data;
But when I go to look at the post in wp-admin, it comes out as:
<php? SELECT *, date_format(event_date, '%m/%d/%y') as new_date FROM events where event_name='hatebreed' = "SELECT *, date_format(event_date, '%m/%d/%y') as new_date FROM events WHERE event_name='hatebreed'"; ?>
It seems I am doing something wrong with the quotes, perhaps, but I can’t for the life of me get it. Any MySQL query concatenator experts out there? Or is this just a WP editor issue that can be solved with a plugin?
- The topic ‘Insert a database query into a post with post object’ is closed to new replies.