php - How to populate multiple items on a different page using a search bar? -


hi wondering if help. have developed search bar site on every page loaded using include function same. code can read database @ lose on how send more 1 result page in format need. problem post 2 3 variables next page in url each link of sort , if search bar returns more 1 result each result need 2 3 variables populate next page.

link example

<a href="page.php?gen=var1&media=var2&order=date_added desc">movies home</a> 

here search bar code.

<?php if(isset($_post['search_term'])){      $search_term = $_post['search_term'];     if (!empty($search_term)) {             $query = "select title database title '%".mysql_real_escape_string($search_term)."%'";             $query_run = mysql_query($query);             $query_num_rows = mysql_num_rows($query_run);             $result = mysql_query($query_num_rows);          if ($query_num_rows >= 1) {             echo $query_num_rows.' results found:<br>';             while ($query_row = mysql_fetch_assoc($query_run)){                 echo $query_row ['title']. '<br>';             }         }         else{             echo 'no results found.';         } }   } ?> 

this code echos on current page. hopeing pass results page , populate multiple items depending on how many results found in search bar. here example of code hopeing populate search bar on target page.

<?php     if (isset($var1)){             $subject_set = mysql_query("select * database genre '%".$info."%' , media = '".$med."' order ".$sort." ", $connection);}                    else{             $subject_set = mysql_query("select * media", $connection);                  }         if (!$subject_set){         die("database connection failed: " . mysql_error());         }        htlm code</div>  <?php } ?> 

i thinking if able pass results id's using array , retrieve corrosponding results database on target page.

sorry still quite novice @ type of coding , hope did not confuse trying say. thank time , can problem sorted. again.

if want display results on other pages, consider putting them in session variables.

<?php  session_start ( ); // @ top of page ...   $theindex=0; while ($query_row = mysql_fetch_assoc($query_run)){     echo $query_row ['title']. '<br>';     $_session['searchresult'][$theindex]  =$query_row ['title'];     $theindex++; 

}

then on page want display results, loop through session['searchresult'] , echo out...

<?php  session_start ( ); // @ top of page  $theresults = $_session['searchresult'];  foreach ($theresults $key=>$value){ echo htmlentities($value) . "<br>";  } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -