• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
just a quickie

[eluser]sore eyes[/eluser]
hi thinkigniter, many thanks for responding. Happy New Year. I'm new to codeigniter and not too much experience with php either, but I do like CI, it seems like a much better way of managing the work and I do enjoy using it.

What I want to do is cycle through records in a database, one at a time. To this end I thought of using the shop_id to select records, and then, to move onto the next record by finding the next larger shop_id and using that to display the next record. The form view, which displays one record and a 'next' button is:


<p>Shop ID &lt;input type="text" name="shop_id" value="&lt;?=$query-&gt;shop_id?&gt;" /></p>
<p>Shop Name &lt;input type="text" name="shopname" value="&lt;?=$query-&gt;shopname?&gt;" /></p>
<p>Shop Name &lt;input type="text" name="phone" value="&lt;?=$query-&gt;phone?&gt;" /></p>
<p>&lt;input type="submit" value="submit" /&gt;&lt;/p>

&lt;!--Go to the next page--&gt;
&lt;?php $old_shop_id=$query->shop_id ?&gt;
&lt;?php echo form_open('welcome/enterNextShop/'.$old_shop_id);?&gt;
<p>&lt;input type="submit" value="goNext"   /&gt;&lt;/p>
&lt;input type="hidden" name="old_shop_id" value="$old_shop_id" /&gt;

The controller (slightly amended) is:

function enterShop()
        $data['main'] = 'shop_view';
        $data['title'] = "Shop";
        $shop_id = $this->uri->segment(3);
        $data['query'] = $this->MShops->getOneShop($shop_id);
    function enterNextShop()
        $old_shop_id = $this->input->post('old_shop_id', TRUE);
        $data = $this->MShops->getNextShop($old_shop_id);
        $shop_id = $this->data->shop_id;

and the model is:
function getOneShop($shop_id)
        $this->db->where('shop_id', $shop_id);
        $data = $this->db->get('shop');
        return $data->row();
    function getNextShop($old_shop_id)
        $this->db->where('shop_id >',$old_shop_id);    
        $data = $this->db->get('shop');
        return $data;

The problem is that the variable is not passing over. When clicking the 'next' button the old_shop_id does not pass to the controller. Also the shop_id in the 'redirect' is not being calculated.

I hope this makes sense to you and am very grateful for your consideration.

Messages In This Thread
just a quickie - by El Forum - 12-30-2008, 11:05 PM
just a quickie - by El Forum - 12-31-2008, 05:02 AM
just a quickie - by El Forum - 12-31-2008, 06:31 PM
just a quickie - by El Forum - 12-31-2008, 07:05 PM
just a quickie - by El Forum - 01-01-2009, 03:30 AM
just a quickie - by El Forum - 01-01-2009, 09:57 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.