- This topic has 3 replies, 2 voices, and was last updated 13 years, 2 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘How do I …’ is closed to new topics and replies.
Events Made Easy › Forums › How do I … › drat event in search result
Hello Franky,
events signed as “draft” are shown in search result. Is it possible that they don’t appear in the results?
Here is my code (http://www.e-dynamics.be/bbpress/topic.php?id=223#post-1056):
<?php
$table = $wpdb->prefix.”dbem_events”;
$s = mysql_real_escape_string($_REQUEST); // The search key words
$found_event = false;
$query = “SELECT * FROM $table WHERE (event_name LIKE ‘%”.$s.”%’) OR
(event_notes LIKE ‘%”.$s.”%’) ORDER BY event_start_date”;
$events = $wpdb->get_results ( $query, ARRAY_A );
print “<div id=’archivebox-events’><h2 class=’silver’>Search results in events</h2></div>”;
foreach ($events as $row) {
print “<div class=’post-alt-events blog’><h3>“.$row.” / “.$row.”</h3>”;
print substr($row,0,250).” …
<span class=’continue’>read more</span>“;
print “</div>”;
print “<div style=’clear:both;’></div>”;
$found_event = true;
}
?>
Thanks a lot.
Change the mysql select to take “event_status” into account. Possible values are:
1 (public)
2 (private)
5 (draft)
Hello Franky,
i change mysql select code to:
$query = “SELECT * FROM $table WHERE ((event_name LIKE ‘%”.$s.”%’) OR
(event_notes LIKE ‘%”.$s.”%’)) AND ‘event_status’ = 1 ORDER BY event_start_date”;
and no events are in search result. What’s wrong in my code, can you help?
Thanks
Try your statements first manually until you find the right yntax for what you want to accomplish.