_user
02-23-2012, 04:44 PM
I have 2 problems and I can't find them.
1. when no results found... I don't get the message "0 results".
2. when found 90 results (for example) and list them 20/page, when I click [page 2] I get page 2 from all data listed (not only those 90 results).
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if ($conn){
mysql_select_db("dbname", $conn);
$per_page = 20;
$pages_query = mysql_query ("SELECT COUNT('ID') FROM table WHERE column LIKE '%$word%' AND column LIKE '%$word%'");
$pages = ceil(mysql_result($pages_query, 0) / $per_page);
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_page;
$query = "SELECT * FROM table WHERE column LIKE '%$word%' AND column LIKE '%$word%' LIMIT $start, $per_page ";
$query_list = "SELECT * FROM table WHERE column LIKE '%$word%' AND column LIKE '%$word%' ";
$results_list = mysql_query($query_list) or die(mysql_error());
$results = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($results_list);
if($count >=1){
$search_output .="<hr />$count rezultats <br />";
while ($row = mysql_fetch_array($results)){
$search_output .= " blablablabla";
}
if($pages >= 1 && $page <= $pages){
for ($x=1; $x<=$pages; $x++){
$page_numerotation .= ($x == $page) ? '<strong>' . $x . '</strong> ' : '<a href="?page=' .$x. '"> ' . $x . '</a> ';
}
}else{
$search_output = "<hr /> 0 rezultats. <hr /><br />";
die(mysql_error());}
}
}
}
and if can anyone help me with an easy pagination
1 to 10 page links than use <back and next> or something like that...
ty in advance
1. when no results found... I don't get the message "0 results".
2. when found 90 results (for example) and list them 20/page, when I click [page 2] I get page 2 from all data listed (not only those 90 results).
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if ($conn){
mysql_select_db("dbname", $conn);
$per_page = 20;
$pages_query = mysql_query ("SELECT COUNT('ID') FROM table WHERE column LIKE '%$word%' AND column LIKE '%$word%'");
$pages = ceil(mysql_result($pages_query, 0) / $per_page);
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_page;
$query = "SELECT * FROM table WHERE column LIKE '%$word%' AND column LIKE '%$word%' LIMIT $start, $per_page ";
$query_list = "SELECT * FROM table WHERE column LIKE '%$word%' AND column LIKE '%$word%' ";
$results_list = mysql_query($query_list) or die(mysql_error());
$results = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($results_list);
if($count >=1){
$search_output .="<hr />$count rezultats <br />";
while ($row = mysql_fetch_array($results)){
$search_output .= " blablablabla";
}
if($pages >= 1 && $page <= $pages){
for ($x=1; $x<=$pages; $x++){
$page_numerotation .= ($x == $page) ? '<strong>' . $x . '</strong> ' : '<a href="?page=' .$x. '"> ' . $x . '</a> ';
}
}else{
$search_output = "<hr /> 0 rezultats. <hr /><br />";
die(mysql_error());}
}
}
}
and if can anyone help me with an easy pagination
1 to 10 page links than use <back and next> or something like that...
ty in advance