me1000 Posted February 11, 2007 Share Posted February 11, 2007 ok I have my search code, but I want to imbed it inside of one index page, My problem is that when i search for something it takes it back to the index page, and not the search results, however the URL after the search is ?cmd=search&words=whateverimsearchingfor&mode=normal but since it isnt including the search.php page inside the index page it only gives me my default index page the URL after you hit search should be ?type=html&page=search&cmd=search&words=whateverimsearchingfor&mode=normal the ?type=html&page=search must be there to show the search form, in my code i dont know where to change it so the URL reflects the change, here is my code, for the whole search // Create the search function: function searchForm() { // Re-usable form // variable setup for the form. $searchwords = (isset($_GET['words']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) : ''); $normal = (($_GET['mode'] == 'normal') ? ' selected="selected"' : '' ); $boolean = (($_GET['mode'] == 'boolean') ? ' selected="selected"' : '' ); echo '<form method="get" action="http://www.site.com/3rd_ani_template/V2/template.php?type=html&page=search">'; echo '<input type="hidden" name="cmd" value="search" />'; echo 'Search for: <input type="text" style="color: #FFFFFF; border: 2px ridge #000000; background-color: #A5A5A5" name="words" value="'.$searchwords.'" /> '; echo 'Mode: '; echo '<select style="color: #FFFFFF; border: 2px ridge #000000; background-color: #A5A5A5" name="mode">'; echo '<option value="normal"'.$normal.'>Normal</option>'; echo '<option value="boolean"'.$boolean.'>Boolean</option>'; echo '</select> '; echo '<input type="submit" style="color: #000; border: 1px ridge #000000; background-color: #A5A5A5" value="Search" />'; echo '</form>'; } // Create the navigation switch $cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : ''); switch($cmd) { default: echo '<h2>Search site!</h2>'; searchForm(); break; case "search": searchForm(); echo '<h3>Search Results:</h3><br />'; $searchstring = mysql_escape_string($_GET['words']); switch($_GET['mode']) { case "normal": $sql = "SELECT ID, PAGE_TITLE, KEYWORDS, MATCH(KEYWORDS) AGAINST ('$searchstring') AS score FROM site_PAGES WHERE MATCH(KEYWORDS) AGAINST ('$searchstring') ORDER BY score DESC"; break; case "boolean": $sql = "SELECT ID, PAGE_TITLE, KEYWORDS, MATCH(KEYWORDS) AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM site_PAGES WHERE MATCH(KEYWORDS) AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score DESC"; break; } // echo $sql; $result = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_object($result)) { echo '<font size="2" face="Arial"><strong>Title: <a href="http://www.site.com/index.php?page_id='.$row->ID.'">'.$row->PAGE_TITLE.'</a></strong><br />'; echo 'Score: '. number_format($row->score, 1); echo '<br>Keywords:</font> <font size="1">'.stripslashes(htmlspecialchars($row->KEYWORDS))."</font>"; echo '<hr size="1" />'; } break; } Any ideas?? Thanks Link to comment https://forums.phpfreaks.com/topic/38047-solved-search-form-variable-url/ Share on other sites More sharing options...
me1000 Posted February 12, 2007 Author Share Posted February 12, 2007 ok well i dont think what i originally wanted to do is possible, however here is my work around, if ($cmd="search" AND $before == "") { header( 'Location: http://www.site.com/3rd_ani_template/V2/template.php?type=html&page=search&before=yes&cmd=search&words='.$words.'&mode='.$mode.'&submit='.$submit ) ; }else{ } however, I have no idea how to add mutable conditions to an if statement, without writing an if statement inside of another! can someone tell me how?? lol nevermind for the record it is if lala && lala then you are singing! lol it works now... Link to comment https://forums.phpfreaks.com/topic/38047-solved-search-form-variable-url/#findComment-182351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.