SQL count example help needed
-
Hi there, I’m trying to learn how to pull info from the database, it’s pretty much the same thing as the SQL COUNT(column_name) Example at w3schools except I’m trying to count the author’s total ‘like_uid’ (likes by user ID) from a table called ‘wp_likes’ and display it on author and post pages.
https://img175.imageshack.us/img175/6621/captureho.png
This is what I had that does not work…
<?php global $wpdb; $liked_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(like_uid) FROM $wpdb->likes WHERE uid = %d", $uid)); echo 'Likes ' . $liked_count . ''; ?>
So it would show ‘likes 5’. I hope I make sense ??
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘SQL count example help needed’ is closed to new replies.