Browse code

search.php: fix very old oversight with Sorting Order (Alphabetical/Most Recent) not working in Advanced Search

Clarissa Walker authored on 2026/11/04 14:46:53
Showing 1 changed files
... ...
@@ -49,7 +49,7 @@ if(isset($_POST['submit']) || isset($_GET['offset'])) {
49 49
 	$output .= "<div id=\"pagetitle\">"._RESULTS."</div>";
50 50
 	$query = array();
51 51
 	$countquery = array();
52
-	$scountquery = array();	
52
+	$scountquery = array();
53 53
 	if($searchtype == "fulltext") {
54 54
 		$query = "SELECT DISTINCT stories.*, "._PENNAMEFIELD." as penname, stories.date as date, stories.updated as updated FROM "._AUTHORTABLE.", ".TABLEPREFIX."fanfiction_stories as stories, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.storytext AND chapter.validated > 0 LIKE '%$searchterm%' AND chapter.sid = stories.sid AND stories.uid = "._UIDFIELD;
55 55
 		$countquery = "SELECT count(DISTINCT stories.sid) FROM ".TABLEPREFIX."fanfiction_stories as stories, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.storytext AND chapter.validated > 0 LIKE '%$searchterm%' AND chapter.sid = stories.sid GROUP BY stories.sid";
... ...
@@ -252,6 +252,7 @@ if(isset($_POST['submit']) || isset($_GET['offset'])) {
252 252
 	if(count($otherresults) > 0) $tpl->assign("otherresults", "<div id='otherresults'><span class='label'>"._OTHERRESULTS.":</span> ".implode(", ", $otherresults)."</div>");
253 253
 }
254 254
 else {
255
+	$disablesorts = array( );
255 256
 	if($searchtype == "simple") {
256 257
 		$output .= "<div id=\"pagetitle\">"._SIMPLE."</div><div style='text-align: center;'><form method=\"post\" enctype=\"multipart/form-data\" action=\"search.php\">
257 258
 		<div class=\"tblborder\" style=\"width: 320px; padding: 5px; margin: 0 auto;\">
... ...
@@ -324,8 +325,10 @@ else {
324 325
   <option>1000</option>
325 326
   <option value='-500'>&lt; 500</option>
326 327
   </select><br /><br /><label for=\"searchterm\">"._SEARCHTERM.": </label><INPUT type=\"text\" class=\"textbox\" name=\"searchterm\" id=\"searchterm\" size=\"20\">
328
+  ";
329
+  
330
+  if(!in_array("sorts", $disablesorts)) $output .= "<label for=\"sortorder\">"._SORT.":</label> <select class=\"textbox\" name=\"sort\"><option value=\"alpha\"".(!$defaultsort ? " selected" : "").">"._ALPHA."</option><option value=\"update\"".($defaultsort == 1 ? " selected" : "").">"._MOSTRECENT."</option></select>";
327 331
   
328
-  <label for=\"sortorder\">"._SORT.":</label> <select name=\"sortorder\" id=\"sortorder\"><option value=\"alpha\">"._ALPHA."</option><option value=\"update\">"._MOSTRECENT."</option></select>";
329 332
 	$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'searchform'");
330 333
 	while($code = dbassoc($codequery)) {
331 334
 		eval($code['code_text']);