Welcome Guest, Not a member yet? Register   Sign In
Problem with joining Ion Auth users table to my posts table..
#1

[eluser]jk215[/eluser]
Before installing Ion Auth I had a users table and listing table. I joined the two so it would display the posts author under it. I installed Ion Auth, remade the users table, and now trying the exact same code and cant get it to work. Any help is appreciated!

It is displaying the posts title, url, and date properly. But says the $username is undefined. I know this has to be from an error on joining the tables. Here is the error"

A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$username
Filename: listings/index.php
Line Number: 6


Model:
Code:
public function get_all_entries()
    {
        $this->db->select('*');
        $this->db->from('listings');
        $this->db->join('users','users.id = listings.listing_by');
        $query = $this->db->get();
        
        if ($query->num_rows() > 0)
        {
            return $query->result();
        }
        else
        {
            return array();
        }
    }

View:
Code:
<?php foreach ($query as $entry) { ?>
  <div class="blog_entry">
   <h2><a >listing_url; ?&gt;">&lt;?php echo $entry->listing_title; ?&gt;</a></h2>
    <span class="metadata">posted by &lt;?php echo $entry->username; ?&gt; &lt;?php echo timespan($entry->listing_date); ?&gt; ago.</span>
  </div><br /><br />
  &lt;?php } ?&gt;
#2

[eluser]jk215[/eluser]
Fixed it. sorry. Delete if possible.




Theme © iAndrew 2016 - Forum software by © MyBB