Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this will give you just the last category from the list
- $sql = "SELECT * FROM " . EVENTS_CATEGORY_TABLE;
- $sql .= " ORDER BY category_name ";
- $event_categories = $wpdb->get_results($sql);
- $num_rows = $wpdb->num_rows;
- if ($num_rows > 0) {
- foreach ($event_categories as $category) {
- $category_id = $category->id;
- $category_name = $category->category_name;
- $in_event_categories = $wpdb->get_results("SELECT * FROM " . EVENTS_CATEGORY_REL_TABLE . " WHERE event_id='" . $event_id . "' AND cat_id='" . $category_id . "'");
- foreach ($in_event_categories as $in_category) {
- $this_event_category = $in_category->cat_id;
- }
- }
- }
- echo $this_event_category;
- //this will give you all the categories associated with the event
- $sql = "SELECT * FROM " . EVENTS_CATEGORY_TABLE;
- $sql .= " ORDER BY category_name ";
- $event_categories = $wpdb->get_results($sql);
- $num_rows = $wpdb->num_rows;
- if ($num_rows > 0) {
- foreach ($event_categories as $category) {
- $category_id = $category->id;
- $category_name = $category->category_name;
- $in_event_categories = $wpdb->get_results("SELECT * FROM " . EVENTS_CATEGORY_REL_TABLE . " WHERE event_id='" . $event_id . "' AND cat_id='" . $category_id . "'");
- foreach ($in_event_categories as $in_category) {
- echo ' '.$in_category->cat_id;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement