here is the php function for content and pagination output:
define("PER_PAGE",15); $page = (!isset($_GET['page'])) ? $page='0' : $page=$_GET['page']; $page = $_GET['page']; $page = $page*PER_PAGE; function preview($sql,$res,$nums){ global $page; $num = ceil($nums/PER_PAGE); $sql .= "LIMIT ".$page.",".PER_PAGE.""; $newRes = mysql_query($sql); if($newRes){ if($row=mysql_num_rows($newRes)>0){ while ($resources = mysql_fetch_array($newRes)){ echo '<div class="block">'; echo '<a href="resource.php?id='.$resources['resources_id'].'"><h3>'.$resources['title'].'</h3></a>'; $string = substr($resources['description'], 0, 300); $string = rtrim($string, "!,.-"); echo '<h4>'.$string.'</h4>'; echo '<h5>'.'Категория : '.$resources['categories'].'</h5>'; $author = $resources["surname"]." ".mb_substr($resources["name"],0,1,'UTF-8').".".mb_substr($resources["middlename"],0,1,'UTF-8')."."; echo '<h5>'.'Автор : '.$author.'</h5>'; echo '</div>'; }; // КОД пагинации for($i=1;$i<=$num;$i++){ echo "<a class='pages' href='lib.php?categories=".$_GET['categories']."&page=".$i."'>".$i."</a> "; } // КОД пагинации }else{ echo "<p class='errmsg'>По Вашему запросу ничего не найдено!</p>"; } } } here is the php function for the query.
function spec(){ $sql = "SELECT * FROM resources LEFT JOIN users ON users.id=resources.author_id LEFT JOIN categories ON categories.categories_id=resources.categories_id LEFT JOIN specialty ON specialty.specialty_id=resources.specialty_id WHERE categories.categories LIKE '%$_GET[categories]%' AND specialty.specialty LIKE '%$_POST[specialty]%' "; preview($sql); } here is the php function for the search button.
function resources() { $cat=$_GET['categories']; $spec=$_POST['specialty']; $key=$_POST['key']; $search=$_POST['search']; if (isset($_POST['submit'])) { if($spec=="Выберите специальность" and ( empty($search) )){ echo "<p class='errmsg'>Что ищем? или Выберите специальность</p>"; }elseif($key=="author" and $spec!="Выберите специальность" and !empty($search)){ fullSearch(); }else if($key=="all"){ if($spec!="Выберите специальность" or ( !empty($search) )){ if(empty($search)){ spec(); }else if($spec=="Выберите специальность"){ search(); }else if($spec!="Выберите специальность" and !empty($search) ){ specSearch(); } } }else if($key!="all" and $key!="author"){ keySearch($key); }else if($key!="all" and $key=="author"){ search(); } } } Problem:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\OpenServer\domains\apk-lib\functions.php on line 337 on this line is
$nums = mysql_num_rows($res);
die($sql);and see what's wrong with you - vp_arth