Welcome Guest, Not a member yet? Register   Sign In
Help with CI, PHP & Javscript
#41

[eluser]the_unforgiven[/eluser]
This is in my view
Code:
<?php foreach($events as $item) : ?>
    <h3>&lt;?php echo anchor('events/getDetails/'.$item->id, 'date'); ?&gt;</h3>
    &lt;?php endforeach; ?&gt;

So how would i pass the $data['events'] through just like that <- ?
#42

[eluser]LuckyFella73[/eluser]
In your controller: when you call the "getDetails" method
to get the details of an event you have to pass the $data['event'] data
to the view where you show the details on the right side
and the event list on the left side.
#43

[eluser]the_unforgiven[/eluser]
Yes i understand the concept but not how to write that, here's my controller for the getDetails method
Code:
function getDetails($id = null) {
            
        if($id != null){
            $data['mainContents'] = $this->Eventsmodel->getRightDetails($id);
        }
        
    
        $data['events'] = $this->Eventsmodel->getRHSDetails();        
        $this->load->view('events', $data);
    }

Thanks for being so patient by the way, really appreciate your help
#44

[eluser]LuckyFella73[/eluser]
Try this:
Code:
function getDetails($id = null) {
            
        if($id != null){
            $data['mainContents'] = $this->Eventsmodel->getRightDetails($id);
        }
        
    
        // $data['events'] = $this->Eventsmodel->getRHSDetails(); // don't know what this is for

    // if this works in your index method then it should work here as well:
    $data['events'] = $this->Eventsmodel->getLeft();

        $this->load->view('events', $data);
    }
#45

[eluser]the_unforgiven[/eluser]
Still getting:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: views/events.php
Line Number: 73
- - - - - - - - - - - - - - - - - - -
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: events
Filename: views/events.php
Line Number: 70
- - - - - - - - - - - - - - - - - - -
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/events.php
Line Number: 70
#46

[eluser]the_unforgiven[/eluser]
I've changed the getDetails method to:
Code:
function getDetails($id = null) {

            if($id != null){
                $data['events'] = $this->Eventsmodel->getRightDetails($id);
                $data['mainContents'] = $this->Eventsmodel->getRightDetails($id);
                $this->load->view('events', $data);
            }

            
        }
Which all links up correctly but still shows 404 page when link clicked its like it not getting the description content from the db even though i have this in my view:
Code:
<div id="display">
    
        &lt;?php foreach($events as $item) : ?&gt;
        <p>&lt;?php echo $item->description ?&gt;</p>
        &lt;?php endforeach; ?&gt;
                
    </div>
#47

[eluser]the_unforgiven[/eluser]
See attached pic on the right is the $item->description left is the links
#48

[eluser]the_unforgiven[/eluser]
any updates?




Theme © iAndrew 2016 - Forum software by © MyBB