Welcome Guest, Not a member yet? Register   Sign In
[Solved] Strange DB results
#1

[eluser]spmckee[/eluser]
So I'm bascially doing a simple "next" and "previous" links thing based on an "order" column I have in my table. What's really weird is that when I try to jump from order number "9" to "10", both ways, it reacts strangely.

Here's my model:
Code:
function next($work_id){
        # Check to see if filtered
        if ($this->session->userdata('cat')){
            $cat = $this->session->userdata('cat');
        }
        
        $this->db->select('seo_url');
        $this->db->order_by('order', 'asc');
        $query = $this->db->get_where('works', array('work_id >' => $work_id, 'status' => 1, 'cat' => $cat), 4, 0);
            
        //if($query->num_rows != 1)
        //  {
        //   $query = $this->db->get_where('works', array('status' => '1', 'cat' => $cat), 1, 0);
        //  }
            foreach ($query->result() as $row)
            {
                echo $row->seo_url;
                echo '<br />';
            }
                        
            
            $next = $query->row()->seo_url;
            return $next;
    }

Now, as you can see I am spitting out 4 results and echoing them, this is just for debugging.

The result I get from the above is:

nike-one-display (order #7)
francis-francis-espresso-maker (order #9)
intel-laptop (order #10)
alpha-tech-medical-animation (order #11)

/*---- I hit "next" ---*/

francis-francis-espresso-maker (order #9)
intel-laptop (order #10)
alpha-tech-medical-animation (order #11)
leatherman-flashlights (order #21)

/*---- I hit "next" ---*/

leatherman-flashlights (order #21)
hagg-lake (order #22)
wacom-tablet (order #23)

As you can see it freaks out after #9 and bypassed #10 and #11. I can't for the life of me figure out why. Any ides? Also, I have a similar setup for "prev" and it does the exact same thing. Ugh!
#2

[eluser]pistolPete[/eluser]
Could you post the entire table with the sample data?
#3

[eluser]spmckee[/eluser]
Thanks for the help. Here is an image of the whole table. Sorry, it's a bit large.

*removed*
#4

[eluser]spmckee[/eluser]
I think I figured it out. I think I am getting the next, greater "work_id" and not "order" but I'm still investigating.

Edit: Yep that was it. Sheesh. thanks for the help anyhow.




Theme © iAndrew 2016 - Forum software by © MyBB