Vote count:
0
SQL is not my strong point but I have a very simple sql query in a snippet as follows...
<?php
$mid = '1';
$subject = stripslashes($wpdb->get_var($wpdb->prepare("SELECT message_subject FROM " . $wpdb->base_prefix . "messages WHERE message_ID = %d", $mid)));
echo $subject
?>
If I feed it with the message id, in this case '1' then it echos out the subject associated with that row.
What I want to do now is do this for a number of $mid variables. Instead of having to specify them manually I want them to be generated for me, I have this so far...
$mid = $wpdb->get_var($wpdb->prepare("SELECT message_ID FROM " . $wpdb->base_prefix . "messages WHERE message_to_user_ID = %d AND message_status = %s", $user_ID, 'unread'));
I know this is probably way off but can someone point me in the right direction of a good example? Do I need something like a foreach loop to go through them all?
asked 1 min ago
SQL Query show all matches
Aucun commentaire:
Enregistrer un commentaire