I think if you add a couple of periods before and after the php variable in your query, remove the use of mysql_fetch_array, and use get_row(), it should work better. Here’s how I would get a park from your custom table:
<?php
$page_title = wp_title('');
$park = $wpdb->get_row("SELECT * FROM $wpdb->park_data WHERE park_name="".$page_title.""");
if($park)
{
print_r($park); // because other than it being an object, I'm not exactly sure what's returned.
}
?>
Also, keep in mind that the mysql query assumes the wp_title() returns the page title formatted exactly the same as the park_name stored in the DB. You may need to format wp_title() to get it to match up with your table data.
It looks like you just want one park returned so I used get_row() instead:
http://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Row
Related Posts:
- the_date() not working
- Delete post revisions on post publish
- How to sort results from a custom database table
- WP database error for comments_popup_link()
- Why is variable not working on custom sql query using wpdb?
- Create WP_Query to search for posts by their categories or their parent/child categories
- Long running queries
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- WordPress SQL injection
- mySQL queries are executed twice on wordpress website
- WordPress Custom Query: Combining Two Functions
- SQL error with custom query
- How can i limit the number of posts to the most recent 6 in my query?
- Query doesn’t display text data with apostrophes
- How to do a MySql query in WordPress?
- How can I display a query in a page?
- Include a custom field in mysql query
- Query Concatenation
- Deprecated: mysql_connect()
- dbDelta support for FOREIGN KEY
- is it possible to run some php code within a wordpress page?
- How to correctly submit a search form and display the result in an independent page
- How to search display_name column when using WP_User_Query
- Does WordPress cache get_user_meta() results?
- How to order posts by modified date without using ‘query_posts’?
- Using Echo in ShortCode – Stuck
- Specific Loop For 2 Within Each
- Modern Tribe Calendar wp-query with meta query not working at all
- How to add a post or page tag to the list of classes appearing in the body tag’s class attribute?
- No wp-config.php file on local install of wordpress – site still displays
- Use ajax to update_post_meta
- Get ID of child from child slug, while knowing parent ID
- Is the outdated PHP mysql extension a requirement for WordPress 4.6?
- What SQL / WordPress queries would need a nonce?
- Different database query in function.php using mysqli
- How can I export posts with featured images, without download them
- Custom filter in admin edit custom post type responding with invalid post type?
- How to securely provide a $_POST var in WP_Query with PHP 7?
- What is a valid parent for get_terms()?
- WSoD being caused by this piece of code
- Calculating a large number of MYSQL queries as customshort codes, slow
- Sum the total amount of a specific product purchased per user and display in table
- Increase offset while looping
- wp query foreach deleting record returning only first or last item
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- $wpdb->wp_users returning empty value for
- How to overwrite orderby with add_query_var
- Make a database query using WordPress
- Force Users To Relogin
- A $_POST should occur when submit form but is not?
- Shortcode to pull posts
- Using CFDB7 vs Custom MySQL Database [closed]
- Using wordpress function to retrieve data
- Querying for specific tags
- Limit tags shown in post
- form $_post action value gets truncated after it passes through two forms
- Adding data to custom wordpress database table
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- making php value numeric
- populate select options from extra mysql table data
- How to store checkbox data for individual users?
- Please help! I have a problem with getting wordpress databas
- Build A Custom SQL Query for WordPress Search
- How to run complex query using PHP
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- Display articles with a different template in the home page | Solved |
- Reading URL Parameters
- Category Page Displaying all Pages
- Usermeta data unserialize, extract and display in table in WordPress
- Conditional formatting on data fetched from MYSQL
- Can I split a huge wp_postmeta table across different databases or servers?
- I can’t separate the array by commas
- WordPress mysql deos not work with php7
- Error inserting into custom table – Object of class wpdb could not be converted to string [closed]
- WP + MySql db / PHP
- The plugin generated 225 characters of unexpected output during activation
- append data to mysql table via submit button coded in php – not working
- WordPress select query issue
- Pagination in WP Queries
- Add two or multiple functions in WordPress Post or Page
- Send data from plugin to external database
- Get posts associated with media attachment
- How to properly send many mysql queries via php and what happens with ajax requests after they are sent?
- How to set max users to 17.000
- Passed variable gets undefined variable error on insert on next page
- directorypress theme error mysql_error() [closed]
- How to set up an auto delete post?
- Unserializeing multiple column values that are stored in one database results variable
- If Elseif Query
- How can I add more code to this?
- Cannot Upload Custom Header Image into WordPress Dashboard
- Does wp_query and query_posts affect website performance? [duplicate]
- Predefine Magazine Style Layouts
- Show post like this image in my newssite [closed]
- Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\admin\products.php on line 148 [closed]
- How to set variable to specific field when querying
- Error resetting database index using ALTER TABLE in $wpdb->query
- Custom Filtering date with newsletter