Pagination (AFTER visiting tutorials!)
Posted: Thu Apr 08, 2004 2:23 pm
Based on information I found in this forum I have checked out a number of pagination tutorials, but I can't quite get mine to work.
I finally ended up athttp://www.phpfreaks.com/tutorials/43/0.php and copied the code. My PHP code now reads as follows:
When I test the page, I get the following error message:
but I can't figure out why it is not a valid argument. 
I finally ended up athttp://www.phpfreaks.com/tutorials/43/0.php and copied the code. My PHP code now reads as follows:
Code: Select all
<?php
<?php
foreach ($_GET as $key => $value) {
$_GET[$key] = trim($value);
}
$limit = 10;
// Sets how many results shown per page
$search_name = (!empty($_GET['member_name'])) ? $_GET['member_name'] : '';
mysql_select_db($database_hschamber, $hschamber);
$sql = "SELECT member_name, member_address1, member_address2, member_city, member_state, member_zip, member_phone, member_fax, member_email, contact_name, web_address FROM Members WHERE member_name LIKE '%$search_name%'";
$result_count = mysql_query($query_count);
// Pulls what we want from the database
$totalrows = mysql_num_rows($result_count);
if(empty($page)){ // Checks if the $page variable is empty (not set)
$page = 1; // If it is empty, we're on page 1
}
$limitvalue = $page * $limit - ($limit);
// Ex: (2 * 25) - 25 = 25 <- data starts at 25
$query = "SELECT * FROM Members LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
// Selects all the data from table.
// mysql_error() will print an error if one occurs.
/* Tip: The MySQL LIMIT value syntax is as follows:
LIMIT $row_to_start_at, $how_many_rows_to_return
*/
if(mysql_num_rows($result) == 0){
echo("Nothing to Display!");
}
// This reads the number of rows returned
// from the result above.
?>Line 14 is:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path/searchNameTEST.php on line 14
Code: Select all
$totalrows = mysql_num_rows($result_count);