Benim arama result.My Arama fonksiyonu için sayfaları yapmaya çalışıyor Im iyi çalışıyor. Ancak, sayfa numarasına tıkladığınızda. Bu hata (aşağıda) görüntülenir:
Notice: Undefined index: search in C:\wamp\www\I-Document\new.php on line 8 ERROR: Select from dropdown
This message only should appear when there is no input in dropdown and no search input. Im not sure how to correct this. Please help! Thank u
<?php
//connecting to the database
include 'config.php';
$search = mysql_escape_string($_POST['search']);
$dropdown = mysql_escape_string($_POST['dropdown']);
if (empty($search) && empty($dropdown)) {
die("Please choose your Search Criteria");
}
//max displayed per page
$per_page = 10;
//get start variable
$start = $_GET['start'];
//count records
$record_count = mysql_query("SELECT COUNT(*) FROM document WHERE $dropdown LIKE '%$search%'");
//count max pages
$max_pages = $record_count / $per_page;
if (!$start)
$start = 0;
//display data
$query = mysql_query("SELECT *
FROM document
WHERE $dropdown LIKE '%$search%'
LIMIT $start, $per_page");
echo "<b><center>Search Result</center></b><br>";
$num=mysql_num_rows($query);
if ($num==0)
echo "No results found";
else {
echo "$num results found!<p>";
}
echo "You searched for <b>$search</b><br /><br /><hr size='1'>";
echo "<table border='1' width='600'>
<th>File Reference No.</th>
<th>File Name</th>
<th>Owner</th>
<th>Borrow</th>
</tr>";
while ($rows = mysql_fetch_assoc($query)) {
echo "<tr>";
echo "<td>". $rows['file_ref'] ."</td>";
echo "<td>". $rows['file_name'] ."</td>";
echo "<td>". $rows['owner'] ."</td>";
echo "<td><a href=add_borrower.php?id=" . $rows['id'] . ">Borrow</a></td>";
echo "</tr>";
}
echo "</table>";
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;
//show prev button
if (!($start<=0))
echo "<a href='new.php?start=$prev'>Prev</a> ";
//show page numbers
//set variable for first page
$i=1;
for ($x=0;$x<$record_count;$x=$x+$per_page) {
if ($start!=$x)
echo " <a href='new.php?start=$x'>$i</a> ";
else
echo " <a href='new.php?start=$x'><b>$i</b></a> ";
$i++;
}
}
//show next button
if (!($start>=$record_count-$per_page))
echo " <a href='new.php?start=$next'>Next</a>";
?>