Search the Community
Showing results for tags 'while search pagination php m'.
-
hi everyone can anyone help me in my code for the search i have a form i have an error this is my code for the form <form name='search' method='post' action''> <input type='text' name='searchtext'> <input type='submit' name='search' value='search'> </form> i put it after the include database on the upper side but its givig me notice undefined index: searchtext here's my php command for the pagination and results //Count the total number of row in your table*/ $count_query = mysql_query("SELECT COUNT(personid) AS numrows FROM persons"); $row = mysql_fetch_array($count_query); $numrows = $row['numrows']; $total_pages = ceil($numrows/$per_page); $reload = 'index.php'; //main query to fetch the data $query = mysql_query("SELECT * FROM persons ORDER by RAND() LIMIT $offset,$per_page"); //loop through fetched data while($result = mysql_fetch_array($query)){ $id = $result['PersonID']; echo "<div class= content > "; echo"<img height=100 width=100 src='upload/". $result['Image'] ."'/>"; echo "<font color='black'>". $result['FirstName']. "</font></br>"; echo "</div>"; i have this query // basic SQL-injection protection $searchText = htmlspecialchars ($_POST['searchText']); // query with simple search criteria $query = mysql_query("SELECT * FROM persons WHERE FirstName LIKE '%" . $searchText . "%' ORDER by RAND() LIMIT $offset,$per_page"); maybe i got wrong because at the start of the page the page start value of searchtext = nothing right is that the reason i'm getting the error? here is the output