Jump to content

passing a variable to the url in with the serialize function


Recommended Posts

<?php  // Run search query    
    $arrResult = mysql_query($strSQL) or die("Cannot execute:". mysql_error());

    while($arrRow = mysql_fetch_assoc($arrResult)) {
        $arrRestaurants[] = $arrRow;
    }
    $pass = serialize($arrRestaurants);
} 

?>
<div id="wrapper">

<form name="frmSearch" class="abajo" action="<?php echo 'indexpagination.php'.$pass.''?>"  method="POST">
    <fieldset class="primero">
        <legend class="primerosub">Search For a Restaurant</legend>

 

I am trying to pass the variable $arrRestaurants through the action form string to indexpagination.php but I don't know if the actual set up is ok.

 

notice I have used the serialize function below the while loop then I use the $pass variable containing the $arrRestaurants variable inside in the action form. but it seems that the variable $pass is not passing throught the url because when I click the submit  form bottom the url results are as follow.

 

But where is the $pass variable in the string?

 

are variable passed through the serialize function hidden as default or am i scripting something wrong?

I can't help but wonder whether you are going about this the best way in the first place... How much data are you trying to pass to the next page? If it is substantial, you might wanna consider passing it as a session variable instead of through a query string.  Alternatively, pass just an id or something and do the actual query on the target page.  Please explain what it is you are trying to accomplish. 

Another member is current fighting problems with a book/tutorial where ALL the results (both expected and errors) that are produced on a page are being passed on the end of the URL to a page where those results are used, rather than just making the page where the results are produced be the same page where the results are finally used.

 

Too many people redirect all over the place, which just makes their site slower (each redirect is another HTTP request from the browser) and results in writing and testing more code.

 

If you are making a real application (not just something for a programming class) you need to make the form and the form processing page be the same page. You will note that every page on this Forum is index.php with the parameters on the end of the URL defining what the page should do, not what data is on the page.

First of I am trying not to get crazy but get this information and ideas handle the way I want.

 

Didn't know that passing variables to another page as of displaying the data in the same page would make the site slower, The only purpose why I wanted to redirect the form action to another page is because of navigation readability. Right now in the web site I am building displaying the results looks disorganized according to a friend suggestion. in Index php i have used the if and else if statement to display html frames according to users input. I think that's a good idea  PFMaBiSmAd.

 

I am having great issues trying to display the results in index.php to indexpagination.php. as you guys has say I don't know if that's the best approach redirecting the form action to another page as of

action="<?php echo'$_SERVER['PHP_SELF']'?>"

 

and then once the page is $_SEVER[php_SELF'] then use the if and else if statements to manage the displaying html.

 

I am also having scripting errors and in www.nyhungry.com/indexpagination.php

 

go to www.nyhungry.com

 

Then in the zip code input type 10468

 

the form action is set to go to indexpagination.php and The script in indexpagination.php is set display 3 rows per page. but when clicked in other pages then the results rows in those pages are not displaying.

 

1- What would be the best approach to use in the action form?

2- what could be causing not to display the other pages rows results?

 

 

2- what could be causing not to display the other pages rows results?

 

could be a number of things.  my guess is that your query is failing (you have not set an offset), or you haven't set proper conditions to accommodate any page(s) other than the first (which is the default display).

it complicates when having to display the rows per page when form actions values sent.

 

The script works well without having a form in the middle.

 

Pagination script from php freaks without having the form input

 

http://localhost/nyhungry/examplepagination.php

 

this is the form

www.nyhungry.com

i can't view your localhost btw.

 

to my understanding, you have well over-complicated your process.

 

drawing items from a database based on a user-inputted search with pagination is pretty straight-forward.  i believe you might need to scrap what you've done and start relatively new with a much more simplified process, in my opinion.

 

no reason you should be sending serialized arrays via URL strings, as well, a form on your page should not affect your scripts.  if it does, it's because something is seriously a miss.  you need to keep your processes separate in that they are their own entity and do not conflict.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.