Page 1 of 1

Help me please isset

Posted: Wed Aug 11, 2010 3:40 am
by Portnumbay
Hi all.. I am stuck now.. please master help me
here is my code

Code: Select all


if(isset($_post['submit']))
{
 $limits   = 5;
 $page = $_GET['page'];
 if(empty($limit)){
	$postion=0;
	$page=1;
}
 //below here is my code for display data from database into table
}  

I am coding display my data from database into table with pagination.. i put a menu list so that user can choose which data he/she wants to be sorted.. for example blackberry, iphone, samsung. after they choose the menu list they click the button submit and table will show data of certain keyword... (blackberry, iphone, etc). the first page no problem.. but as my coding to go to the second page.. they need to click '2' (the second page) which will be ?page=blabla .. I want to get this value, but my $_GET['page'] is inside the isset.. how to do it ? for now if i click the second page the table will not show the data...

Re: Help me please isset

Posted: Wed Aug 11, 2010 8:36 am
by shawngoldw
It doesn't show the data because it is all within the isset($_POST['submit']). When you click 2 and go to page.php?page=2 you are not submitting the form so the post['submit'] is not set.

I would suggest making your form with blackberry, etc... get instead of post and instead of isset($_POST['submit']) use $_GET['type']. Make sure you pass this type along though when you click on 2, or 3, etc...


Shawn

Re: Help me please isset

Posted: Wed Aug 11, 2010 8:50 am
by PradeepKr
Why are you using both GET and POST in the same code?
Either use one of the two methods GET/POST or use $_REQUEST instead which would not bother about the method being a get or post.

Code: Select all

if(isset($_REQUEST['submit']))
{
    $limits   = 5;
    $page = $_REQUEST['page'];
    if(empty($limit)){
        $postion=0;
        $page=1;
     }
 //below here is my code for display data from database into table
}

Re: Help me please isset

Posted: Wed Aug 11, 2010 9:52 am
by shawngoldw
Using get and post together is fine to do, I do it all the time. Although yes, in this case it just doesn't work.

Re: Help me please isset

Posted: Wed Aug 11, 2010 11:42 am
by Portnumbay
shawngoldw wrote:It doesn't show the data because it is all within the isset($_POST['submit']). When you click 2 and go to page.php?page=2 you are not submitting the form so the post['submit'] is not set.

I would suggest making your form with blackberry, etc... get instead of post and instead of isset($_POST['submit']) use $_GET['type']. Make sure you pass this type along though when you click on 2, or 3, etc...


Shawn
yeah thats the problem.. i confuse how to get the post inside the isset.. i thought maybe there's syntax in php where i can set the isset already click.. Yeah i was about to make it different file but its only choose the category so i can combine them.. Thanks anyway for replying...

Re: Help me please isset

Posted: Wed Aug 11, 2010 11:43 am
by Portnumbay
PradeepKr wrote:Why are you using both GET and POST in the same code?
Either use one of the two methods GET/POST or use $_REQUEST instead which would not bother about the method being a get or post.

Code: Select all

if(isset($_REQUEST['submit']))
{
    $limits   = 5;
    $page = $_REQUEST['page'];
    if(empty($limit)){
        $postion=0;
        $page=1;
     }
 //below here is my code for display data from database into table
}
even if i use the request the if(isset($_REQUEST['submit'])) will not be executed.. Thanks anyway

Re: Help me please isset

Posted: Tue Sep 14, 2010 4:04 am
by PradeepKr
Then I am sure something is wrong with your form which submits the data.

check if it is something like this,

<input type="submit" name="submit" value="Submit">