Jump to content


Where Condition With POST / GET Not Work

where post ajax_list

  • Please log in to reply
7 replies to this topic

#1 mnish

mnish

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationIndia

Posted 03 September 2013 - 08:02 AM

I Want to sort my table on the basis of form post but the result display only for minor time after that crud shown 'No Item to display'. Why?
 
My Form is:-
 
<form action="<?php echo base_url(); ?>product1" method="post" name="f1">
        <input type="text" name="product_id" value="" />
        <input type="submit" name="submit" value="submit" />
</form>
 
 
 
And My Function  is:
 
 
function product1()
{
$pid = isset($_POST['product_id'])?$_POST['product_id']:'';
 
$this->load->library('grocery_crud');
$crud = new grocery_CRUD();
$crud->where('product_id',$pid);
$crud->set_table('product_main');
$crud->set_subject('Product');
$crud->fields('product_name','product_id');
 
$crud->required_fields('product_name');
 
$output = $crud->render();
 
$this->load->view('_product_crud', $output);
 
}
 
i am also use 
$pid = $this->input->post('product_id');
or $pid = $_POST['product_id'];
 
when i give static value to $pid it works fine..
 
Where Is the Problem..?
 
 
 Plz Help Me...

 



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 04 September 2013 - 02:38 AM

I don't think it will work like this, having a form where the grid (listing) is.

If you really need to do that use either of the following :

 

1. create two separate views and on one load your form and on the other the crud. call both views from one controller function

2. ajaxify the form

3. make two differenet controller functions, one for the host one for the crud. the host will contain the form and upon submit will pass the $pid to the other crud function. make sure on this crud function you use the http://www.grocerycr...t_crud_url_path . Obviously you will need to make a composite (combined) view 

 

 Well In general this is not a Grocery CRUD issue. It is an MVC design -  architecture topic. Good luck.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 mnish

mnish

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationIndia

Posted 06 September 2013 - 05:51 PM

 Well In general this is not a Grocery CRUD issue. It is an MVC design -  architecture topic. Good luck.

 

My Friend Davidoster Plz don't mind i think this is the grocery crud issue because  if we send post data to function where we use grocery crud library.

if we change form post value to static value(i.e. where('product_id',4)) crud works fine but if use form post value into where clause the clause not work so i think this the the GC issue.

By the way you are Grocery CRUD Ninja so you are right... :)



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 06 September 2013 - 10:03 PM

mnish Ninja doesn't mean anything!

And who's right it doesn't matter. What matters is to help each other here!

And by the way you said it yourself, when sending a static value on the where it works. Doesn't this mean that GC works also?

So check the value you send from the form!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 07 September 2013 - 03:47 PM

Well Mr. mnish,

 

You can verify the value reaching out to the code / function by many ways...

1 - u can use firefox with firebug addon

2 - u can print_r($_POST)

 

First - verify what id it is being used to pass the value to the function.. and is it really being passed in or not.



#6 mnish

mnish

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationIndia

Posted 07 September 2013 - 04:24 PM

Thanx Mr Amit For giving me some beautiful tips but I have already tried both option.

 

Can you giving an example where we use $crud->where('field_name',$this->input->post('post_variable_name')); thanx in advance.



#7 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 07 September 2013 - 10:00 PM

Thanx Mr Amit For giving me some beautiful tips but I have already tried both option.

 

Can you giving an example where we use $crud->where('field_name',$this->input->post('post_variable_name')); thanx in advance.

 

As the documentation says, http://www.grocerycr...functions/where

check CI's where since it is exactly the same.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#8 timenz

timenz

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 01 January 2015 - 11:33 AM

affect me also, it's happen because when we load page, it's receive post/get parameter, then after loading grocery crud refresh the result by run ajax request (index/ajax_list),

the problem is, this ajax request don't have our post/get data, so the result reseted as same as without post/get data.







Also tagged with one or more of these keywords: where, post, ajax_list

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users