co.ador Posted December 12, 2009 Share Posted December 12, 2009 <?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. http://localhost/stores/indexpagination.php 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? Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/ Share on other sites More sharing options...
RichardRotterdam Posted December 12, 2009 Share Posted December 12, 2009 A couple of questions for you: What does code (html/php) of your form look like? What type of data is " $arrRestaurants"? Why do you need serialize()? Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-975973 Share on other sites More sharing options...
.josh Posted December 12, 2009 Share Posted December 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976008 Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2009 Share Posted December 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976013 Share on other sites More sharing options...
co.ador Posted December 12, 2009 Author Share Posted December 12, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976026 Share on other sites More sharing options...
mrMarcus Posted December 12, 2009 Share Posted December 12, 2009 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). Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976027 Share on other sites More sharing options...
co.ador Posted December 12, 2009 Author Share Posted December 12, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976029 Share on other sites More sharing options...
mrMarcus Posted December 12, 2009 Share Posted December 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976038 Share on other sites More sharing options...
co.ador Posted December 12, 2009 Author Share Posted December 12, 2009 lol sorry http://www.nyhungry.com/examplepagination.php Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976042 Share on other sites More sharing options...
co.ador Posted December 12, 2009 Author Share Posted December 12, 2009 Let's start from the action form Ok what do you suggest to set the action form to <?php $_SERVER['PHP_SELF']?> or to a page1.php? Quote Link to comment https://forums.phpfreaks.com/topic/184880-passing-a-variable-to-the-url-in-with-the-serialize-function/#findComment-976045 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.