justlukeyou Posted February 28, 2011 Share Posted February 28, 2011 Hi, I have a website which displays products on product display pages and static pages such as 'contact us'. I am now looking to add a search function which directs to the display page so the products are neatly presented. However, all the tutorials I can find are based on displaying the echo on same page as the search and directing the search to another page. Does anyone know how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/229127-php-search-to-display-page/ Share on other sites More sharing options...
Muddy_Funster Posted February 28, 2011 Share Posted February 28, 2011 ....However, all the tutorials I can find are based on displaying the echo on same page as the search and directing the search to another page. Does anyone know how to do this? I'm confuzzled what do you want to do? Quote Link to comment https://forums.phpfreaks.com/topic/229127-php-search-to-display-page/#findComment-1180855 Share on other sites More sharing options...
justlukeyou Posted February 28, 2011 Author Share Posted February 28, 2011 Hi, I want people to search my database from any page on my site but return the results on product display page. I have the product display page in place which works. I just to run search form queries on it along with pre-written links. Quote Link to comment https://forums.phpfreaks.com/topic/229127-php-search-to-display-page/#findComment-1180861 Share on other sites More sharing options...
Muddy_Funster Posted February 28, 2011 Share Posted February 28, 2011 just code a search form into your pages <form action = "product_display.php" method ="POST"> <label>Search</label><input type = "text" name="search" value="" /><input type="submit" value="Search" /> </form> as long as your product display page knows to use $_POST['search'] to get it's result set it'll work from any page you include it on. that what your looking for? Quote Link to comment https://forums.phpfreaks.com/topic/229127-php-search-to-display-page/#findComment-1180864 Share on other sites More sharing options...
justlukeyou Posted February 28, 2011 Author Share Posted February 28, 2011 Thanks, I thought the search form use $_POST and the display page used $_GET. I really need a step by step guide to this sort of code. I bought a book but the examples are very poor and not based on commercial examples. Quote Link to comment https://forums.phpfreaks.com/topic/229127-php-search-to-display-page/#findComment-1180872 Share on other sites More sharing options...
Muddy_Funster Posted February 28, 2011 Share Posted February 28, 2011 a book would be a big help, for refference if nothing else (even a cavant would have difficulty remembering everything about php) but if a form is involved you will POST the data from the form to your php. if the variable atributes are comming from an outside source (such as the URL header - most commonly) then you will need php to go GET the values. whatever method of transporting the values you choose to use, just remember that you have to use the same on both sides (only an issue with forms really) so if you are using 'method="POST" ' then you will use $_POST['varName'] to retieve the value likewise, if you use 'method="GET" ' then you will need to use $_GET['varName'] to retrieve it. Also, some hosting only allows one or another method of trasfering values between pages, so take that into account when you are making your pages (assuming you have access to that information at designe time). Quote Link to comment https://forums.phpfreaks.com/topic/229127-php-search-to-display-page/#findComment-1180884 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.