Title: Get events from database
Last modified: August 24, 2016

---

# Get events from database

 *  [allampatu](https://wordpress.org/support/users/allampatu/)
 * (@allampatu)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/get-events-from-database/)
 * Hello Developer,
    I have two running wp site in a same database and in one of
   them I’ve setup your event plugin.
 * I’ve added the code below to get the same events on other site pulling out directly
   from the database, so I add events just one time.
 * I would like to ask you how can i add the start date on the event and how i have
   to improve the sql code.
 * When I’ve added the StartDate value from the table eo_events i get duplicated
   results.
    For example, every dates is present, it’s attacched for every single
   event.
 * I know it’s a bit tricky but I hope you can help me.
    Thanks a lot
 *     ```
       $mydb = new wpdb('user','pass','database','host');
       $events = $mydb->get_results("SELECT post_title, post_name, StartDate FROM wp_posts, eo_events WHERE post_type = 'event'");
   
       foreach ($events as $obj) : ?>
       <div id="<?php echo $obj->post_id; ?>" class="fusion-one-third one_third fusion-layout-column fusion-column spacing-yes post">
        <div class="fusion-date-and-formats">
            <div class="fusion-date-box updated">
               <span class="fusion-date">
                   <?php echo date('j', strtotime($obj->StartDate)); ?></span>
               <span class="fusion-month-year">
                   <?php
           setlocale(LC_ALL, 'it_IT');
           echo strftime('%b %Y', strtotime($obj->StartDate));
                   ?></span>
           </div>
        <div class="fusion-format-box"><i class="fa fa-calendar"></i></div>
       </div>
        <div class="fusion-post-content post-content">
            <h2 class="entry-title">
               <a target="_blank" href="<?php echo $obj->post_name; ?>"><?php echo $obj->post_title; ?></a>
            </h2>
        </div>
       </div>
   
       <? endforeach; ?>
       ```
   
 * screenshot:
    currently I’ve just six events, look how many i get 🙁 [IMG]http://
   i57.tinypic.com/209fz8g.png[/IMG] [screenshot](http://i57.tinypic.com/209fz8g.png)
 * [https://wordpress.org/plugins/event-organiser/](https://wordpress.org/plugins/event-organiser/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Stephen Harris](https://wordpress.org/support/users/stephenharris/)
 * (@stephenharris)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/get-events-from-database/#post-6178929)
 * You’ll need join the eo_events table.
 *  Thread Starter [allampatu](https://wordpress.org/support/users/allampatu/)
 * (@allampatu)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/get-events-from-database/#post-6178930)
 * you mean this?
    `$events = $mydb->get_results("SELECT post_title, post_name, 
   StartDate FROM wp_posts, INNER JOIN eo_events WHERE post_type = 'event'");`
 * thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 The topic ‘Get events from database’ is closed to new replies.

 * ![](https://ps.w.org/event-organiser/assets/icon-256x256.png?rev=978123)
 * [Event Organiser](https://wordpress.org/plugins/event-organiser/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/event-organiser/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/event-organiser/)
 * [Active Topics](https://wordpress.org/support/plugin/event-organiser/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/event-organiser/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/event-organiser/reviews/)

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [events](https://wordpress.org/support/topic-tag/events/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * 2 replies
 * 2 participants
 * Last reply from: [allampatu](https://wordpress.org/support/users/allampatu/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/get-events-from-database/#post-6178930)
 * Status: not resolved