Help me please isset

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Portnumbay
Forum Newbie
Posts: 14
Joined: Mon Jul 05, 2010 1:22 am

Help me please isset

Post 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...
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Help me please isset

Post 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
PradeepKr
Forum Newbie
Posts: 14
Joined: Wed Aug 11, 2010 8:29 am

Re: Help me please isset

Post 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
}
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Help me please isset

Post 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.
Portnumbay
Forum Newbie
Posts: 14
Joined: Mon Jul 05, 2010 1:22 am

Re: Help me please isset

Post 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...
Portnumbay
Forum Newbie
Posts: 14
Joined: Mon Jul 05, 2010 1:22 am

Re: Help me please isset

Post 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
PradeepKr
Forum Newbie
Posts: 14
Joined: Wed Aug 11, 2010 8:29 am

Re: Help me please isset

Post 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">
Post Reply