<?php mysql_connect("localhost","root",""); mysql_select_db("library"); ?>
<?php include('../db.php'); if($_GET['page']) { $page =$_GET['page']; } $per_page_num=2; $offset = ($page-1)* $per_page_num; $getdata = ("select * from author limit $offset,1"); $checking = mysql_query($getdata); //if($checking=== FALSE) { // die(mysql_error()); // TODO: better error handling //} while ($rows = mysql_fetch_array($checking)) { ?> <?=$rows['name']?><br/> <?php } ?>
<?php include("../db.php"); $query = mysql_query("select * from author"); $count = mysql_num_rows($query); $per_page=1; $total = ceil($count/$per_page); ?> <ul id="paginate"> <?php for ($i=1;$i<=$total;$i++) { ?> <li id="<?=$i?>"><?=$i?></li> <?php } ?> </ul> <div id="content"></div> <div id="load"></div> <script src="../jquery.js" type="text/javascript"></script> <script> $(document).ready(function(){ function display(){ $("#load").fadeIn("slow"); $("#load").html('<img src="https://themarketingoak.files.wordpress.com/2015/07/circle-loading-animation.gif">'); } function hide(){ $("#load").fadeOut(3000); } $("#paginate li:first").css({color:"red"}); display(); $("#content").load('data.php?page=1',hide()); $("#paginate li").click(function(){ display(); $("#paginate li").css({color:"blue"}); $(this).css({color:"red"}); var num=$(this).id; $("#content").load('data.php?page='+ num,hide()); }); }); </script>
mysql_query
$checking = mysql_query($getdata); //if($checking=== FALSE) { // die(mysql_error()); // TODO: better error handling //}
mysql_fetch_array() expects parameter 1 to be resource (or mysqli_result), boolean given | StackOverflow[^]: A query may fail for various reasons in which case both the mysql_* and the mysqli extension will return false from their respective query functions/methods. You need to test for that error condition and handle it accordingly.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)