i have a seach script. the $search is taken from a $_POST, thats fine , for page 1 where the data was posted, how can i alter my code so i get the variable accross any search result? Thanx.
<?php
// Database Connection
include 'db.php';
$page = GETENV('SCRIPT_NAME');
$search = $_POST['search'];
///////////////navigation code
if(empty($frm))
$frm = 0;
$to = 10;//decides the number of rows per page
//find the total numbe of rows
$sql = "SELECT * FROM archive WHERE name = '$search' AND approved = '1'";//my query
$total_rows = mysql_num_rows(mysql_query($sql));
//create the navigation bar
if($total_rows > $to)
{
$forward_frm = $frm+$to;
$back_frm = $frm-$to;
if($frm < $to){
$navigation = "<font size=1>(Showing ".$frm." to ".$forward_frm." of ".$total_rows.")</font> <a href=\"".$page."?frm=".$forward_frm."\">Next >></a>";
}
elseif($frm >= $to && $frm < $total_rows-$to){
$navigation = "<font size=1>(Showing ".$frm." to ".$forward_frm." of ".$total_rows.")</font> <a href=\"".$page."?frm=".$back_frm."\"><< Prev</a> | <a href=\"".$page."?frm=".$forward_frm."\">Next >></a>";
}
elseif(($forward_frm) >= $total_rows){
$whats_left = $frm + ($total_rows - $frm);
$navigation = "<font size=1>(Showing ".$frm." to ".$whats_left." of ".$total_rows.")</font> <a href=\"".$page."?frm=".$back_frm."\"><< Prev</a> | <a href=\"".$page."\">Start >></a>";
}
}
////////////////////////////end navigation code///////////////////////////////////////
$sql = mysql_query("SELECT * FROM archive WHERE name = '$search' AND approved = '1' LIMIT $frm, $to");
echo "<table width=90% align=center border=1 bordercolor=#111111 style=border-collapse: collapse>
<caption align=right>$navigation</caption>
<tr>
<font face='Tahoma'>
<td align=center bgcolor=#FFFFFF><font face='Tahoma'>ID</td>
<td align=center bgcolor=#FFFFFF><font face='Tahoma'>File Name</td>
<td align=center bgcolor=#FFFFFF><font face='Tahoma'>Author</td>
</tr></font>";
while($row = mysql_fetch_array($sql)){
// Build your formatted results here.
$name = $row['name'];
$author = $row['author'];
$ref = $row['ref'];
$authorurl = $row['authorurl'];
$printname = "<a href=file.php?id=$ref>$name</a>";
$printauthor = "<a href=$authorurl>$author</a>";
echo "<tr>
<td align=center>$ref</td>
<td align=center>$printname</td>
<td align=center>$printauthor</td>";
}
echo "</center>";
?>