Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6902319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:47:01+00:00 2026-05-27T07:47:01+00:00

Disclaimer: I’m new to Web Development So Far: I’ve been passing primary key data

  • 0

Disclaimer: I’m new to Web Development

So Far: I’ve been passing primary key data from a MySQL database table into the id=”” field of the calendar class library list item that is displayed on the calendar when generated, and I’ve also been passing another value associated with the row of its respective primary key to the list item as well.

Scenario: I’m needing to pass another value from the same respective row of the primary key into the class=”” of the list item, and I’ve hit a wall. I may need to create a new function in my modal, or do something within the controller where said calendar is generated, or I may be totally overlooking something completely simple. Regardless, I could use some very appreciated help. Thank you so much!

P.S. Please let me know if you need anymore information to help me out. Thanks again! You’re all wonderful!

Model:

class Events_model extends crud_model {

    public function __construct()
    {
        parent::__construct();

        $this->pk = 'id';
        $this->table_name = 'events';
    }

    public function get_events_for_calendar($user_id, $year = FALSE, $month = FALSE)
    {

        if ( ! $year )
        {
            $year = date("Y");
        }

        if ( ! $month )
        {
            $month = date("m");
        }

        $this->db->where("user_id", $user_id);
        $events = parent::get_all();

        $cal_events = array();

        foreach ($events as $e)
        {
            if ( date("Y", $e->date) == $year && date("m", $e->date) == $month)
            {       
                $day = intval( date("d", $e->date));

                //Swap out to change between displaying type or title of events listed -lrussell810

                //$cal_events[$day][$e->id] = $e->type;
                $cal_events[$day][$e->id] = $e->title;
            }
        }
        return $cal_events;
    }

Controller:

$this->load->library('calendar', $config);

        $title['title'] = 'Planner';

        $data = $this->events->get_events_for_calendar($this->end_user->id, $this->uri->segment(4), $this->uri->segment(5));

        $calendar['calendar'] = $this->calendar->generate($this->uri->segment(4), $this->uri->segment(5), $data);

        $this->load->view('public/head_view', $title);
        $this->load->view('user/header_view');
        $this->load->view('user/planner_view', $calendar);
        $this->load->view('user/footer_view');

Calendar Library:

// If more than one event on the same day
                      if (is_array($data[$day]))
                      {
                        $several_events = '';
                        foreach ($data[$day] as $key => $value)
                        {
                          $several_events .= '<li class="" id="'.$key.'">'.$value.'</li>';
                        }
                        $out .= str_replace('{day}', $day, str_replace('{content}', $several_events, $temp));
                      }

Other Calendar Library Information:

// --------------------------------------------------------------------

    /**
     * Initialize the user preferences
     *
     * Accepts an associative array as input, containing display preferences
     *
     * @access  public
     * @param   array   config preferences
     * @return  void
     */
    function initialize($config = array())
    {
        foreach ($config as $key => $val)
        {
            if (isset($this->$key))
            {
                $this->$key = $val;
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:47:01+00:00Added an answer on May 27, 2026 at 7:47 am

    If I understood correctly you want to add ‘more’ to your event when it is output visually as html, so you are adding referencing pk’s as ID’s (hence my comment above).

    You can create an associative array for each event like so:

        $cal_events = array();
    
        foreach ($events as $e)
        {
            if ( date("Y", $e->date) == $year && date("m", $e->date) == $month)
            {       
                $day = intval( date("d", $e->date));
    
                //just made up examples below
                $cal_events[$day][$e->id]['class'] = $e->class;
                $cal_events[$day][$e->id]['type'] = $e->type;
                $cal_events[$day][$e->id]['id'] = $e->title; 
            }
        }
        return $cal_events;
    

    You would then later reference that array in your calendar library like so:

    // If more than one event on the same day
    if (is_array($data[$day])){
        $several_events = '';
        foreach ($data[$day] as $key => $value)
        {
            $several_events .= '<li class="'.$value['class'].'" id="'.$value['id'].'">'.$value['type'].'</li>';
        }
        $out .= str_replace('{day}', $day, str_replace('{content}', $several_events, $temp));
    }
    

    Hopefully that’s what you are looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer : I'm new to web development. Scenario : I've built an application using
Disclaimer: I am very new to iOS development. Please excuse the possible stupidity of
Disclaimer: I'm fairly new to python! If I want all the lines of a
Disclaimer: I'm completely new to Java EE/EJB and all that, so bear with me.
Disclaimer: I'm trying to learn proper OO programming/design, so I'm pretty new to this
[Disclaimer: I am new to PHP, and I am just learning, so please no
DISCLAIMER: relatively new to Flex/AS3, I might be missing something obvious. After doing some
[DISCLAIMER: My development machine is running OS X Tiger, so my question and experiences
Disclaimer: I'm very new to SQL and databases in general. I need to create
Disclaimer: Never used php in my life. New to Unix and Jenkins I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.