02-07-2011, 07:24 PM
[eluser]codedoode[/eluser]
I'm having a problem getting a getting two separate MySQL tables to display on one page.
This is my controller code
This is my model code
This is my view
I'm assuming it's a problem with the way I'm writing my If statements on the view page, but then again I have no idea. This is one of maybe issues I'm running into when putting the finishing touches on this new website I'm building. Can anyone help me get this working or provide insight as to why this isn't working? THANK YOU TO ANYONE WHO HELPS IN ADVANCE!
I'm having a problem getting a getting two separate MySQL tables to display on one page.
This is my controller code
Code:
function index()
{
$submissions = array();
if($query = $this->site_model->get_records())
{
$submissions['records'] = $query;
}
$votes = array();
if($query = $this->site_model->get_votes())
{
$votes['data'] = $query;
}
$this->load->view('list_view', $submissions, $votes);
}
This is my model code
Code:
function get_records()
{
$this->db->order_by('id', 'desc');
$query = $this->db->get('submissions');
return $query->result();
}
function get_votes()
{
$this->db->order_by('id', 'desc');
$query = $this->db->get('votes');
return $query->result();
}
This is my view
Code:
<!-- start post -->
<div class="post">
<?php if(isset($records)) : foreach($records as $row) : ?>
<h1><?=anchor('http://example.com/'.$row->username, $row->username); ?></h1>
<p>
<?php echo $row->message; ?>
</p>
<ul id="info">
<li><a href="#">2 days ago</a></li>
</ul>
<?php if(isset($data)) : foreach($data as $row) : ?>
<ul id="voting">
<li><a href="#"><?php echo $row->hilarious; ?> Hilarious</a></li>
<li><a href="#"><?php echo $row->boring; ?> Boring</a></li>
<li><a href="#"><?php echo $row->retweet; ?> I'd ReTweet</a></li>
<li><a href="#"><?php echo $row->favorite; ?> Favorite</a></li>
</ul>
<?php endforeach; ?>
<?php else : ?>
<ul id="voting">
<li>No Votes were found.</li>
</ul>
<?php endif; ?>
<div id="like">
[removed][removed]
<fb:like href="<?php echo 'http://example.com/staging/index.php/site/post/'.$row->id ?>" layout="button_count" show_faces="false" width="150"></fb:like>
</div>
<img src="images/divider.png" class="divider" alt="divider" />
<?php endforeach; ?>
<?php else : ?>
<p>No submissions were found.</p>
<?php endif; ?>
</div>
<!-- end post -->
I'm assuming it's a problem with the way I'm writing my If statements on the view page, but then again I have no idea. This is one of maybe issues I'm running into when putting the finishing touches on this new website I'm building. Can anyone help me get this working or provide insight as to why this isn't working? THANK YOU TO ANYONE WHO HELPS IN ADVANCE!