Trying to display results from an sql query in PHP:
SELECT *
FROM wp_celebcount
ORDER BY count DESC
I'm trying to display two columns: wp_celebcount.name & wp_celebcount.count
Having trouble getting the result to show with PHP - I want to show this result on my index.php Wordpress theme file. Thanks for the help...
If you're using Wordpress, it would be something like this:
global $wpdb;
$result = $wpdb->get_results('SELECT name, count FROM wp_celebcount');
foreach($result as $row) {
echo 'Name: '.$row->name.', Count: '.$row->count.'<br/>';
}
It's recommended to use the $wpdb global as it takes care of all the database setup for you.
More information on $wpdb can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With