Ich brauche Hilfe bei der Suche nach Kommentaren (es ist für eine WordPress-Website).PHP/MySQL - Suchanfrage
Kommentare sind diese Weg- abgerufen, wenn der Benutzer angemeldet ist:
$comments = $wpdb->get_results($wpdb->prepare("
SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d
AND (comment_approved = '1' OR (user_id = %d AND comment_approved = '0'))
ORDER BY comment_date_gmt", $post->ID, $user_ID));
wenn nicht:
$comments = $wpdb->get_results($wpdb->prepare("
SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d
AND (comment_approved = '1' OR (comment_author = %s
AND comment_author_email = %s AND comment_approved = '0'))
ORDER BY comment_date_gmt",
$post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES),
$comment_author_email));
so ich, wie ich Kommentare filtern können, die einen bestimmten Suchbegriff, wie $_GET['search_query']
enthalten ?
Dies ist WP database structure. Der Suchbegriff ich suche ist in comment_content
danke, ich werde es versuchen. Was macht das Prozentzeichen vor und nach $ _GET? – Alex