Code: Select all
<link href="styles.css" rel="stylesheet" type="text/css">
<form action="searchtest2.php" method="post">
Search - <input type="text" name="search" value="<?php if($_POST['search']) echo $_POST['search']; ?>" /><br />
<input type="submit" name="searchbtn" value="Search" />
</form>
<?php
include ('dbc.php'); // Connect to the data base.
if($_POST['searchbtn']) {
echo '<br /><br />';
if(!get_magic_quotes_gpc()) {
$search = addslashes($_POST['search']);
} else {
$search = $_POST['search'];
}
$query = "SELECT full_name,user_idnum,DATE_FORMAT(`date`, '%m/%d/%Y %I:%i %p'),book,returned, MATCH (full_name) AGAINST ('".$search."' IN BOOLEAN MODE) AS full_name FROM `checkout` WHERE MATCH (full_name) AGAINST ('".$search."' IN BOOLEAN MODE) ORDER BY `full_name` DESC";
$result = mysql_query($query);
$num = mysql_num_rows($result);
}
$max = 10; //amount of articles per page. change to what to want
$p = $_GET['p'];
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
//view the news article!
if(isset($_GET['act']) && $_GET['act'] == "view")
{
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM checkout WHERE id = '$id'");
while($r = mysql_fetch_array($sql))
{
$full_name = $r['full_name'];
$user_idnum = $r['user_idnum'];
$date = $r['date'];
$book = $r['book'];
$returned = $r['returned'];
echo "<div><p>$full_name</p><p>$user_idnum</p><p>$date</p><p>$book</p><p>$returned</p></div>";
}
}else{
//view all the news articles in rows
$sql = $result;
//the total rows in the table
$totalres = ($num);
//the total number of pages (calculated result), math stuff...
$totalpages = ceil($totalres / $max);
//the table
echo '<table align="center" cellspacing="2" cellpadding="2"><tr><td align="left"><b>Name</b></td><td align="center"><b>ID</b></td><td align="center"><b>Date</b></td><td align="center"><b>Book</b></td><td align="center"><b>Returned</b></td></tr><tr>';
while ($r = mysql_fetch_array($sql, MYSQL_NUM)) {
echo "<tr><td align=\"left\">" .
stripslashes($r[0]) . "</td>
<td align=\"left\">$r[1]</td>
<td align=\"left\">$r[2]</td>
<td align=\"left\">$r[3]</td>
<td align=\"left\">$r[4]</td><tr>\n";
}
}
//close up the table
echo "</tr></table>";
echo( "<div style='text-align: center;'>" );
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
$counter = "<a href='searchtest2.php?p=$i'>$i</a>";
echo "<span class=\"csstables\">$counter</span>";
}
echo( "</div>" );
?>if ($_POST['submit'] == 'search') {
at the beginning of the script but that causes it not load anything when I push the search button.
Any ideas on how I could fix this so that you can actually view the results onn the next page instead of resetting the forums?