roldahayes Posted April 7, 2009 Share Posted April 7, 2009 Hi, Hope I am explaining this clearly enough...! I have a search script that displays information about different stores located in a database. When you click search, the page jumps to a new page with the results. As I am using this script within a page, I would like the results to be displayed on the SAME PAGE and not jump to another one. www.viewmykitchen.com the script that is called into the page using an includes is <?php // ---------------------------------------------------------------------- // File : locator.php // Description : search and display list/view of stores // Version : 1.0 // Created : 1/6/2007 // // Copyright (c) 2007. All rights reserved. // // ---------------------------------------------------------------------- include("settings.php"); include("databasewrapper.php"); include("includes/countrydropdown.php"); print("<style>\n"); include("locator.css"); print("</style>\n"); //Allow for magic quotes if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } //accept variables if (isset($_REQUEST['search'])) $strSearch = addslashes($_REQUEST['search']); else $strSearch = ""; if (isset($_REQUEST['key'])) $strKey = addslashes($_REQUEST['key']); else $strKey = ""; if (isset($_REQUEST['stateID'])) $strState = addslashes($_REQUEST['stateID']); else $strState = ""; if (isset($_REQUEST['country'])) $strCountry = addslashes($_REQUEST['country']); else $strCountry = ""; if (isset($_REQUEST['storeID'])) $intStoreID = addslashes($_REQUEST['storeID']); else $intStoreID = ""; if (isset($_REQUEST['pn'])) $intPage = $_REQUEST['pn']; else $intPage = 1; $intStartrecord = (($intPage*$intPublicpagesize)-($intPublicpagesize)); //maintain state between pages $strPublicstate = get_public_state(0); $strNavpublicstate = get_public_state(1); //main page control logic print("<div id=\"locatorcontainer\">\n"); if ($intStoreID != "") { location_info($intStoreID); } else { if ($strSearch != "") { sql_prep(); $intRecordsfound = record_count($SQLstmt); $intTotalpages = get_page_total(); if ($intRecordsfound > 0) { sql_for_results(); search_feedback(); results_status(); location_list(); display_paged_navigation(); } else { search_feedback(); no_records_found(); } } else { location_search(); } } print("</div>\n"); // end locatorcontainer div // ---------------------------------------------------------------------- // Function : location_search // Description : prints a search form to query store locations // Usage : location_search() // // ---------------------------------------------------------------------- function location_search() { global $SetStateSearch, $SetCountrySearch; print("<div id=\"locatorform\">\n"); print("<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n"); print(" <tr>\n"); print(" <td class=\"locatorheading\">Find a Kitchen in your area</td>\n"); print(" </tr>\n"); print(" <tr><td align=\"right\" class=\"viewall\"><a href=\"" . $_SERVER['PHP_SELF'] . "?search=true\">view all</a></td></tr>\n"); print(" <tr>\n"); print("<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">\n"); print("<input type=\"hidden\" name=\"search\" value=\"true\">\n"); print(" <td class=\"formtext\"><span class=\"formheading\">Keyword</span> (Business Name, Postcode, Town or County etc.)<br>"); print("<input type=\"text\" name=\"key\"></td>\n"); print(" </tr>\n"); //if state search enabled if ($SetStateSearch == "ON") { print(" <tr>\n"); print(" <td>"); print("<span class=\"formheading\">County</span><br>\n"); include("includes/statedropdown.php"); print(" </td>\n"); print(" </tr>\n"); } //if country search enabled if ($SetCountrySearch == "ON") { print(" <tr>\n"); print(" <td>"); print("<span class=\"formheading\">Country</span><br>\n"); countrydropdown(); print(" </td>\n"); print(" </tr>\n"); } print(" <tr><td height=\"8\"></td></tr>\n"); print(" <tr>\n"); print(" <td><input type=\"image\" src=\"images/formbutton.gif\" value=\"submit\" border=\"0\"></td>\n"); print(" </tr>\n"); print("</form>\n"); print("</table>\n"); print("</div>\n"); // end locatorform div } // ---------------------------------------------------------------------- // Function : location_list // Description : prints a list of stores based on search parameters // Usage : location_list() // // ---------------------------------------------------------------------- function location_list() { global $SQLstmt; global $strPublicstate; global $SetShowCountry; print("<div id=\"searchresults\">\n"); $resultSet = dbaction($SQLstmt); while ($row = getrsrow($resultSet)) { print("<div class=\"storerow\">\n"); if ($row['storename'] != "") print("<div class=\"rowheading\"><a href=\"" . $_SERVER['PHP_SELF'] . "?storeID=" . $row['storeID'] . "$strPublicstate\">" . $row['storename'] . "</a></div>\n"); if ($row['address'] != "") print $row['address'] . "<br>"; // build address remainder $strBuildaddress = ""; if ($row['suburb'] != "") $strBuildaddress .= $row['suburb']; if ($row['city'] != "") { if ($strBuildaddress != "") $strBuildaddress .= ", "; $strBuildaddress .= $row['city']; } if ($row['statename'] != "") { if ($row['suburb'] != "" || $row['city'] != "") $strBuildaddress .= ", "; $strBuildaddress .= $row['statename'] . "."; } if ($row['country'] != "" || $row['zippostcode'] != "") { $strBuildaddress .= "<br>"; if ($SetShowCountry == "ON") { if ($row['country'] != "") $strBuildaddress .= $row['country'] . " "; } if ($row['zippostcode'] != "") $strBuildaddress .= $row['zippostcode']; } if ($strBuildaddress != "") print $strBuildaddress; if ($row['telephone1'] != "") print "<br>" . $row['telephone1']; if ($row['telephone2'] != "") print "<br>" . $row['telephone2']; if ($row['maplink'] != "") { print("<div id=\"resultmaplink\">\n"); print("<a href=\"http://" . $row['maplink'] . "\" target=\"_blank\">View Profile</a> "); print("<a href=\"http://" . $row['maplink'] . "\" target=\"_blank\"><img src=\"images/mapicon.gif\" border=\"0\"></a>"); print("</div>\n"); } print("\n</div>\n"); // end storerow div } print("</div>\n"); // end searchresults div } // ---------------------------------------------------------------------- // Function : location_info // Description : prints complete information on a store // Usage : location_info($storeID) // // ---------------------------------------------------------------------- function location_info($storeID) { global $strPublicstate; global $SetShowStoreHours; global $SetShowCountry; $SQLstmt = "SELECT slstore.*, slstate.statename FROM slstore " . "LEFT JOIN slstate ON slstore.stateID = slstate.stateID " . "WHERE storeID = '$storeID'"; $resultSet = dbaction($SQLstmt); $row = getrsrow($resultSet); print("<div id=\"fullinfocontainer\">\n"); //return to results list link print("<div id=\"backtoresults\"><a href=\"" . $_SERVER['PHP_SELF'] . "?search=true$strPublicstate\">Back to results</a></div>\n"); print("<div id=\"fullinfotopsep\"></div>\n"); print("<div id=\"storename\">" . $row['storename'] ."</div>\n"); print("<div id=\"addressdescription\">\n"); print("<div id=\"addressbox\">\n"); if ($row['address'] != "") print $row['address'] . "<br>"; // build address remainder $strBuildaddress = ""; if ($row['suburb'] != "") $strBuildaddress .= $row['suburb']; if ($row['city'] != "") { if ($strBuildaddress != "") $strBuildaddress .= ", "; $strBuildaddress .= $row['city']; } if ($row['statename'] != "") { if ($row['suburb'] != "" || $row['city'] != "") $strBuildaddress .= ", "; $strBuildaddress .= $row['statename'] . "."; } if ($row['country'] != "" || $row['zippostcode'] != "") { $strBuildaddress .= "<br>"; if ($SetShowCountry == "ON") { if ($row['country'] != "") $strBuildaddress .= $row['country'] . " "; } if ($row['zippostcode'] != "") $strBuildaddress .= $row['zippostcode']; } if ($strBuildaddress != "") print $strBuildaddress; // telephone numbers if ($row['telephone1'] != "") print "<br>" . $row['telephone1']; if ($row['telephone2'] != "") print "<br>" . $row['telephone2']; print("</div>\n"); // end addressbox div print("<div id=\"descriptionbox\">\n"); if ($row['description'] != "") print $row['description']; print("</div>\n"); print("</div>\n"); // end addressdescription div //other comms if ($row['fax'] != "" || $row['website'] != "" || $row['email']) { print("<div id=\"othercomms\">\n"); print("<table cellpadding=\"0\" cellspacing=\"2\" border=\"0\">\n"); if ($row['fax'] != "") { print("<tr><td class=\"othercommstext\">Fax:</td><td class=\"othercommstext\">" . $row['fax'] . "</td></tr>\n"); } if ($row['website'] != "") { print("<tr><td class=\"othercommstext\">Website:</td><td class=\"othercommstext\"><a href=\"http://" . $row['website'] . "\" target=\"_blank\">" . $row['website'] . "</a></td></tr>\n"); } if ($row['email'] != "") { print("<tr><td class=\"othercommstext\">Email:</td><td class=\"othercommstext\"><a href=\"mailto:" . $row['email'] . "\">" . $row['email'] . "</td></tr>\n"); } print("</table>\n"); print("</div>\n"); } if ($SetShowStoreHours == "ON") { print("<div id=\"storehours\">\n"); if ($row['openmonday'] != "" || $row['closemonday'] != "" || $row['opentuesday'] != "" || $row['closetuesday'] != "" || $row['openwednesday'] != "" || $row['closewednesday'] != "" || $row['openthursday'] != "" || $row['closethursday'] != "" || $row['openfriday'] != "" || $row['closefriday'] != "" || $row['opensaturday'] != "" || $row['closesaturday'] != "" || $row['opensunday'] != "" || $row['closesunday'] != "") { //store hours print("<span class=\"fullheading\">Store Hours</span><br>\n"); print("<table cellpadding=\"0\" cellspacing=\"2\" border=\"0\">\n"); print(" <tr>\n"); print(" <td class=\"hourstext\"></td><td class=\"hourstext\">Open</td><td></td><td class=\"hourstext\">Close</td>\n"); print(" </tr>\n"); if ($row['openmonday'] != "" || $row['closemonday'] != "") { print(" <tr>\n"); print(" <td class=\"hourstext\" width=\"92\">Monday</td><td class=\"hourstext\">" . $row['openmonday'] . "</td><td>-</td><td class=\"hourstext\">" . $row['closemonday'] . "</td>"); print(" </tr>\n"); } if ($row['opentuesday'] !="" || $row['closetuesday'] != "") { print(" <tr>\n"); print(" <td class=\"hourstext\">Tuesday</td><td class=\"hourstext\">" . $row['opentuesday'] . "</td><td>-</td><td class=\"hourstext\">" . $row['closetuesday'] . "</td>"); print(" </tr>\n"); } if ($row['openwednesday'] !="" || $row['closewednesday'] != "") { print(" <tr>\n"); print(" <td class=\"hourstext\">Wednesday</td><td class=\"hourstext\">" . $row['openwednesday'] . "</td><td>-</td><td class=\"hourstext\">" . $row['closewednesday'] . "</td>"); print(" </tr>\n"); } if ($row['openthursday'] !="" || $row['closethursday'] != "") { print(" <tr>\n"); print(" <td class=\"hourstext\">Thursday</td><td class=\"hourstext\">" . $row['openthursday'] . "</td><td>-</td><td class=\"hourstext\">" . $row['closethursday'] . "</td>"); print(" </tr>\n"); } if ($row['openfriday'] !="" || $row['closefriday'] != "") { print(" <tr>\n"); print(" <td class=\"hourstext\">Friday</td><td class=\"hourstext\">" . $row['openfriday'] . "</td><td>-</td><td class=\"hourstext\">" . $row['closefriday'] . "</td>"); print(" </tr>\n"); } if ($row['opensaturday'] !="" || $row['closesaturday'] != "") { print(" <tr>\n"); print(" <td class=\"hourstext\">Saturday</td><td class=\"hourstext\">" . $row['opensaturday'] . "</td><td>-</td><td class=\"hourstext\">" . $row['closesaturday'] . "</td>"); print(" </tr>\n"); } if ($row['opensunday'] !="" || $row['closesunday'] != "") { print(" <tr>\n"); print(" <td class=\"hourstext\">Sunday</td><td class=\"hourstext\">" . $row['opensunday'] . "</td><td>-</td><td class=\"hourstext\">" . $row['closesunday'] . "</td>"); print(" </tr>\n"); } print("</table>\n"); } if ($row['opencloseinfo'] != "") { print ("<div id=\"extrahours\">" . $row['opencloseinfo'] . "</div>\n"); } print("</div>\n"); // end storehours div } //store manager if ($row['storemanager'] != "") print("<div id=\"storemanager\"><span class=\"fullheading\">Store Manager</span><br> " . $row['storemanager'] . "</div>\n"); //map link and directions if ($row['maplink'] != "") print("<div id=\"maplink\"><a href=\"http://" . $row['maplink'] . "\" target=\"_blank\">View Map</a></div>\n"); if ($row['directions'] != "") print("<div id=\"directions\"><span class=\"fullheading\">Directions</span><br>" . $row['directions'] . "</div>"); print("<div id=\"fullinfobottomsep\"></div>\n"); print("</div>\n"); // end fullinfocontainer } // ---------------------------------------------------------------------- // Function : sql_prep // Description : sets SQL variables to find number of records found // and prepare to run main query // Usage : sql_prep() // // ---------------------------------------------------------------------- function sql_prep() { global $SQLstmt, $SQLselect, $SQLfrom, $SQLwhere; global $strKey, $strState, $strCountry; global $SetDebug; //Build FROM part $SQLfrom = " FROM slstore LEFT JOIN slstate ON slstore.stateID = slstate.stateID"; //Build WHERE part $SQLwhere = " WHERE (recordstatus = 'active')"; if ($strKey != "" || $strState != "" || $strCountry != "") { if ($strKey != "") { $SQLwhere .= " AND (storename LIKE '%$strKey%' OR address LIKE '%$strKey%'" . " OR city LIKE '%$strKey%' OR suburb LIKE '%$strKey%' OR statename LIKE '%$strKey%'" . " OR country LIKE '%$strKey%' OR zippostcode LIKE '%$strKey%')"; } if ($strState != "") { $SQLwhere .= " AND (slstore.stateID = $strState)"; } if ($strCountry != "") { $SQLwhere .= " AND (country = '$strCountry')"; } } //SQL to find number of records $SQLselect = "SELECT COUNT(*)"; $SQLstmt = $SQLselect . $SQLfrom . $SQLwhere; if ($SetDebug == "ON") { print("<div class=\"debug\">$SQLstmt</div>"); } } // ---------------------------------------------------------------------- // Function : sql_for_results // Description : creates the remainder of the sql parts required and // sets the actual record retrieval SQL query // Usage : sql_for_results() // // ---------------------------------------------------------------------- function sql_for_results() { global $SQLstmt, $SQLselect, $SQLfrom, $SQLwhere, $SQLorder; global $intStartrecord; global $intPublicpagesize; global $SetDebug; //SQL to retrieve all or a subset of store records $SQLselect = "SELECT storeID, storename, address, city, suburb, country, " . "statename, zippostcode, telephone1, telephone2, maplink"; $SQLorder = " ORDER BY storename"; $SQLlimit = " LIMIT $intStartrecord, $intPublicpagesize"; $SQLstmt = $SQLselect . $SQLfrom . $SQLwhere . $SQLorder . $SQLlimit; if ($SetDebug == "ON") { print("<div class=\"debug\">$SQLstmt</div>\n"); } } // ---------------------------------------------------------------------- // Function : record_count // Description : returns number of records found during search // Usage : record_count($SQLstmt) // Parameters : $SQLstmt - SQL for total query record count // Returns : $intRecordsfound - how many records will be returned // by query // // ---------------------------------------------------------------------- function record_count($SQLstmt) { $resultSet = dbaction($SQLstmt); $row = getrsrow($resultSet); $intRecordsfound = $row[0]; return $intRecordsfound; } // ---------------------------------------------------------------------- // Function : get_page_total // Description : return the number of record result pages available // using the total number of records found and the // page size from the settings.php file // Usage : get_page_total() // Returns : intTotalpages - how many record result pages there are // given the number of records found and the page size // setting // // ---------------------------------------------------------------------- function get_page_total() { global $intRecordsfound; global $intPublicpagesize; if (fmod($intRecordsfound, $intPublicpagesize) == 0) { $intTotalpages = $intRecordsfound/$intPublicpagesize; } else { $intTotalpages = ceil($intRecordsfound/$intPublicpagesize); } return $intTotalpages; } // ---------------------------------------------------------------------- // Function : search_feedback // Description : prints feedback on search parameters // Usage : search_feedback() // // ---------------------------------------------------------------------- function search_feedback() { global $strKey, $strState, $strCountry; print("<div id=\"searchfeedback\">\n"); if ($strKey != "" || $strState != "" || $strCountry != "") { print("You searched on "); if ($strKey != "") print("Keyword: <span class=\"searchfeedbackbold\">" . stripslashes($strKey) . "</span> "); if ($strState != "") { $SQLstmt2 = "SELECT statename FROM slstate WHERE stateID = '$strState'"; $resultSet2 = dbaction($SQLstmt2); $row = getrsrow($resultSet2); print("County: <span class=\"searchfeedbackbold\">" . $row['statename'] . "</span> "); } if ($strCountry != "") print("Country: <span class=\"searchfeedbackbold\">" . stripslashes($strCountry) . "</span> "); } print("<span class=\"searchagain\"><a href=\"" . $_SERVER['PHP_SELF'] . "\">new search</a></span>\n"); print("</div>\n"); // end searchfeedback div } // ---------------------------------------------------------------------- // Function : results_status // Description : shows status info on the number of records returned in // a result list and which ones are currently shown // Usage : resultsstatus() // // ---------------------------------------------------------------------- function results_status() { global $intRecordsfound; global $intPage; global $intStartrecord; global $intPublicpagesize; print("<div id=\"recordsfound\">"); print("Showing results <span class=\"recordsfoundbold\">" . ($intStartrecord+1) . ""); print("</span> - <span class=\"recordsfoundbold\">"); if (($intPublicpagesize*$intPage) < $intRecordsfound) print($intPublicpagesize*$intPage); else print($intRecordsfound); print(" </span> of <span class=\"recordsfoundbold\">$intRecordsfound</span>"); print("</div>\n"); } // ---------------------------------------------------------------------- // Function : no_records_found // Description : print no records found message // Usage : norecordsfound() // // ---------------------------------------------------------------------- function no_records_found() { print("<div id=\"norecordsfound\">No records found</div>\n"); } // ---------------------------------------------------------------------- // Function : display_paged_navigation // Description : diplays the page navigation links when a search // result has more than 1 page of records // Usage : display_paged_navigation() // // ---------------------------------------------------------------------- function display_paged_navigation() { global $intTotalpages; global $intPage; global $intPublicchaptersize; global $strNavpublicstate; // only show page navigation links if number of pages > 1 if ($intTotalpages > 1) { // calculate current chapter based on current page if (fmod($intPage, $intPublicchaptersize) == 0) $intChapter = ($intPage/$intPublicchaptersize); else $intChapter = ceil($intPage/$intPublicchaptersize); // display paged record navigation bar print("<div id=\"pagenavcontainer\">\n"); print("<div id=\"pagenavigation\">\n"); // display previous chapter link if it exists if ($intChapter > 1) { print("<div id=\"pagenavprev\">"); print("<a href=\"" . $_SERVER['PHP_SELF'] . "?search=true$strNavpublicstate"); print("&pn=" . ((($intChapter-1)*$intPublicchaptersize)-$intPublicchaptersize+1) . ""); print("\">Prev $intPublicchaptersize pages</a>"); print("</div>\n"); } // display page links $intStartat = (($intChapter*$intPublicchaptersize) - ($intPublicchaptersize - 1)); if ($intTotalpages < ($intChapter*$intPublicchaptersize)) $intFinishat = $intTotalpages; else $intFinishat = ($intChapter*$intPublicchaptersize); for($x=$intStartat;$x<=$intFinishat;$x++) { if ($intPage == $x) { print("<div class=\"pagenavbox\">$x</div>\n"); } else { print("<div class=\"pagenavbox\">"); print("<a href=\"" . $_SERVER['PHP_SELF'] . "?search=true$strNavpublicstate&pn=$x"); print("\">$x</a></div>\n"); } } // display next chapter link if it exists if (($intChapter * $intPublicchaptersize) < $intTotalpages) { print("<div id=\"pagenavnext\">"); print("<a href=\"" . $_SERVER['PHP_SELF'] . "?search=true$strNavpublicstate"); print("&pn=" . (($intChapter*$intPublicchaptersize)+1) . ""); print("\">Next $intPublicchaptersize pages</a>"); print("</div>\n"); } print("</div>\n"); // end pagenavigation div print("</div>\n"); // end pagenavcontainer div } // end if total pages > 0 } // ---------------------------------------------------------------------- // Function : get_public_state // Description : return part of a querystring which can be added to // links to maintain search state // Usage : get_public_state($intMode) // Arguments : $intMode - identifies whether to return querystring // components for general or page navigation // links // // ---------------------------------------------------------------------- function get_public_state($intMode) { $strPublicstate = ""; $strNavpublicstate = ""; if (isset($_REQUEST['key'])) { if ($_REQUEST['key'] != "") { $strPublicstate .= "&key=" . urlencode($_REQUEST['key']); } } if (isset($_REQUEST['stateID'])) { if ($_REQUEST['stateID'] != "") { $strPublicstate .= "&stateID=" . urlencode($_REQUEST['stateID']); } } if (isset($_REQUEST['country'])) { if ($_REQUEST['country'] != "") { $strPublicstate .= "&country=" . urlencode($_REQUEST['country']); } } $strNavpublicstate = $strPublicstate; if (isset($_REQUEST['pn'])) { $strPublicstate .= "&pn=" . $_REQUEST['pn']; } //return result based on $intMode supplied if ($intMode == 0) { //pass back querystring version of current state return $strPublicstate; } else if ($intMode == 1) { //pass back querystring version of current state for navigation links return $strNavpublicstate; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/ Share on other sites More sharing options...
phil88 Posted April 7, 2009 Share Posted April 7, 2009 You'd need to use javascript for that. Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-803937 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 You'd need to use javascript for that. Really !!?!! okay try this (kinda need the page with the search form) change <form action="/locator.php" method="post"> to <form action="" method="post"> and add the following code if(isset($_POST['search'])) { include "/locator.php"; }else{ ?> //the html you want to replaced with the found set goes here <?php } Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-803938 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 The search form is located in the locator.php page - its all in one. Ok, so I have... print("<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">\n"); Is this the line I need to edit? Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-803956 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 try changing print("<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">\n"); to print("<form action=\"\" method=\"post\">\n"); should do the trick, Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-803968 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 Excellent, thanks for that, Now where abouts do I need to add if(isset($_POST['search'])) { include "/locator.php"; }else{ ?> //the html you want to replaced with the found set goes here <?php } I place it straight under the edited "method post" line but it dosn't seem to do any thing? Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-803972 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 Na.. that shouldn't be needed, you just need the include "/locator.php"; on the page where you want the search or the resultes Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-803979 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 I've already got include "/locator.php"; in the page which calls the search box - when you search now it just reloads the page? www.viewmykitchen.com type "bell" in the search box to see what I mean Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804006 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 can you post the code from the main page.. or atleast the code around the include "/locator.php"; theirs probably an if block ie if($_POST['search']) { Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804015 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 The page is using joomla, so its just an include in one of the articles... I'll post the index.php page to see if that helps. What is strange though is that if you go to www.viewmykitchen.com/locator.php everything seems to work fine... <?php /** * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" > <head> <jdoc:include type="head" /> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" /> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" /> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template.css" type="text/css" /> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php echo $this->params->get('colorVariation'); ?>.css" type="text/css" /> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php echo $this->params->get('backgroundVariation'); ?>_bg.css" type="text/css" /> <!--[if lte IE 6]> <link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/ieonly.css" rel="stylesheet" type="text/css" /> <![endif]--> <?php if($this->direction == 'rtl') : ?> <link href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template_rtl.css" rel="stylesheet" type="text/css" /> <?php endif; ?> </head> <body id="page_bg" class="color_<?php echo $this->params->get('colorVariation'); ?> bg_<?php echo $this->params->get('backgroundVariation'); ?> width_<?php echo $this->params->get('widthStyle'); ?>"> <a name="up" id="up"></a> <div class="center" align="center"> <div id="wrapper"> <div id="wrapper_r"> <div id="header"> <div id="header_l"> <div id="header_r"> <div id="logo"></div> <jdoc:include type="modules" name="top" /> </div> </div> </div> <div id="tabarea"> <div id="tabarea_l"> <div id="tabarea_r"> <div id="tabmenu"> <table cellpadding="0" cellspacing="0" class="pill"> <tr> <td class="pill_l"> </td> <td class="pill_m"> <div id="pillmenu"> <jdoc:include type="modules" name="user3" /> </div> </td> <td class="pill_r"> </td> </tr> </table> </div> </div> </div> </div> <div id="search"> <jdoc:include type="modules" name="user4" /> </div> <div id="pathway"> <jdoc:include type="modules" name="breadcrumb" /> </div> <div class="clr"></div> <div id="whitebox"> <div id="whitebox_t"> <div id="whitebox_tl"> <div id="whitebox_tr"></div> </div> </div> <div id="whitebox_m"> <div id="area"> <jdoc:include type="message" /> <div id="leftcolumn"> <?php if($this->countModules('left')) : ?> <jdoc:include type="modules" name="left" style="rounded" /> <?php endif; ?> </div> <?php if($this->countModules('left')) : ?> <div id="maincolumn"> <?php else: ?> <div id="maincolumn_full"> <?php endif; ?> <?php if($this->countModules('user1 or user2')) : ?> <table class="nopad user1user2"> <tr valign="top"> <?php if($this->countModules('user1')) : ?> <td> <jdoc:include type="modules" name="user1" style="xhtml" /> </td> <?php endif; ?> <?php if($this->countModules('user1 and user2')) : ?> <td class="greyline"> </td> <?php endif; ?> <?php if($this->countModules('user2')) : ?> <td> <jdoc:include type="modules" name="user2" style="xhtml" /> </td> <?php endif; ?> </tr> </table> <div id="maindivider"></div> <?php endif; ?> <table class="nopad"> <tr valign="top"> <td> <jdoc:include type="component" /> <jdoc:include type="modules" name="footer" style="xhtml"/> </td> <?php if($this->countModules('right') and JRequest::getCmd('layout') != 'form') : ?> <td class="greyline"> </td> <td width="170"> <jdoc:include type="modules" name="right" style="xhtml"/> </td> <?php endif; ?> </tr> </table> </div> <div class="clr"></div> </div> <div class="clr"></div> </div> <div id="whitebox_b"> <div id="whitebox_bl"> <div id="whitebox_br"></div> </div> </div> </div> <div id="footerspacer"></div> </div> <div id="footer"> <div id="footer_l"> <div id="footer_r"> <p id="syndicate"> <jdoc:include type="modules" name="syndicate" /> </p> <p id="power_by"> <?php echo JText::_('Design & Hosting By ') ?> <a href="http://www.gkmedia.co.uk">GK Media</a>. <?php echo JText::_('Valid') ?> <a href="http://validator.w3.org/check/referer">XHTML</a> <?php echo JText::_('and') ?> <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>. </p> </div> </div> </div> </div> </div> <jdoc:include type="modules" name="debug" /> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804023 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 Nope that doesn't help i need the part that has the include statment.. from what i can tell include isn't on that page! Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804029 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 the include is just written in the code of an article, litteraly just: <?php include("http://www.viewmykitchen.com/locator.php"); ?> entered in the html.... Could it be to do with the below code? this seems to tell it to print the results and there is a line similar to the one that you suggested changing earlier? The . $_SERVER['PHP_SELF'] . part? // ---------------------------------------------------------------------- // Function : location_list // Description : prints a list of stores based on search parameters // Usage : location_list() // // ---------------------------------------------------------------------- function location_list() { global $SQLstmt; global $strPublicstate; global $SetShowCountry; print("<div id=\"searchresults\">\n"); $resultSet = dbaction($SQLstmt); while ($row = getrsrow($resultSet)) { print("<div class=\"storerow\">\n"); if ($row['storename'] != "") print("<div class=\"rowheading\"><a href=\"" . $_SERVER['PHP_SELF'] . "?storeID=" . $row['storeID'] . "$strPublicstate\">" . $row['storename'] . "</a></div>\n"); if ($row['address'] != "") print $row['address'] . "<br>"; // build address remainder $strBuildaddress = ""; if ($row['suburb'] != "") $strBuildaddress .= $row['suburb']; if ($row['city'] != "") { if ($strBuildaddress != "") $strBuildaddress .= ", "; $strBuildaddress .= $row['city']; } if ($row['statename'] != "") { if ($row['suburb'] != "" || $row['city'] != "") $strBuildaddress .= ", "; $strBuildaddress .= $row['statename'] . "."; } if ($row['country'] != "" || $row['zippostcode'] != "") { $strBuildaddress .= "<br>"; if ($SetShowCountry == "ON") { if ($row['country'] != "") $strBuildaddress .= $row['country'] . " "; } if ($row['zippostcode'] != "") $strBuildaddress .= $row['zippostcode']; } if ($strBuildaddress != "") print $strBuildaddress; if ($row['telephone1'] != "") print "<br>" . $row['telephone1']; if ($row['telephone2'] != "") print "<br>" . $row['telephone2']; if ($row['maplink'] != "") { print("<div id=\"resultmaplink\">\n"); print("<a href=\"http://" . $row['maplink'] . "\" target=\"_blank\">View Profile</a> "); print("<a href=\"http://" . $row['maplink'] . "\" target=\"_blank\"><img src=\"images/mapicon.gif\" border=\"0\"></a>"); print("</div>\n"); } print("\n</div>\n"); // end storerow div } print("</div>\n"); // end searchresults div } Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804033 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 for some reason posts are not being picked up on the main page.. i'm not sure if that joomla it some other code edit.. other that this post have any other changes been made ? Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804037 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 Nope, no other changes - so the problem must be joomla then? Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804041 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 I would guess so! but that also seams weird to me! try adding the following <?php var_dump($_REQUEST);//add include("http://www.viewmykitchen.com/locator.php"); ?> your going to want to remove that line later, its just to test to see if the requests are getting to their! Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804043 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 search donsnt display at all now Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804048 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 My mistake, entered it wrong! Search box is back with this code above it array(9) { ["ja_purity_tpl"]=> string(9) "ja_purity" ["0ff92feef3a87d88bcd8d9f9e41c8ea9"]=> string(26) "u89kugdd61894679laknjv6f85" ["PHPSESSID"]=> string(26) "l0b4fgrvgk0imkr3durl00o0j5" ["db7bd10e8a3b59f850a7f0e8cdb7e3e1"]=> string(26) "c8b231c2gdn83dfv3jcvn5sc14" ["option"]=> string(11) "com_content" ["view"]=> string(9) "frontpage" ["Itemid"]=> string(1) "1" ["layout"]=> string(7) "default" ["limit"]=> int(9) } Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804052 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 okay well that seams fine! remove var_dump($_REQUEST);//add and put it the locator.php file //main page control logic var_dump($_REQUEST);//HERE print("<div id=\"locatorcontainer\">\n"); Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804057 Share on other sites More sharing options...
phil88 Posted April 7, 2009 Share Posted April 7, 2009 You'd need to use javascript for that. D'oh! I totally misread the question. Apologies! Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804058 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 Ok, now have array(0) { } above the search box Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804059 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 its kinda strange but thats a good thing, were getting some where! okay leave that line in.. we need it to get some results okay.. i'm going to guess and say its the magic quotes routine that messing it up! lets disable it for now change if (get_magic_quotes_gpc()) { to if (get_magic_quotes_gpc() && FALSE) { edit: revised code Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804063 Share on other sites More sharing options...
roldahayes Posted April 7, 2009 Author Share Posted April 7, 2009 Ok, done, still appears the same on the included page but if you search from the real page it does bring up a lot of code Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804066 Share on other sites More sharing options...
MadTechie Posted April 7, 2009 Share Posted April 7, 2009 okay.. i kinda hoped for some better news! but from the main page i still get array(0) { } please confirm you added the && FALSE if you did then, let try something that should get a results at the top of the file <?php var_dump($_REQUEST);//HERE // ---------------------------------------------------------------------- // and revert back on the other change change if (get_magic_quotes_gpc() && FALSE) { back to if (get_magic_quotes_gpc()) { Also are you using an Entension for Joomla to include this file? Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804071 Share on other sites More sharing options...
roldahayes Posted April 8, 2009 Author Share Posted April 8, 2009 Ok, changes made. Yes I am using a plugin to allow PHP commands in Joomla. Link for this is http://www.kksou.com/php-gtk2/Joomla/DirectPHP-plugin.php Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804076 Share on other sites More sharing options...
MadTechie Posted April 8, 2009 Share Posted April 8, 2009 Okay well including a file seams to have some limitations, so try copying the contents of locator.php and pasting it into Joomla Quote Link to comment https://forums.phpfreaks.com/topic/153062-need-help-with-displaying-reults-on-same-page-please/#findComment-804089 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.