mysql - Pagination PHP addressbook -


i building table of users in domain. got table working , put little code pagination in keep getting errors...

//connection $conn = new mysqli($servername, $username, $password, $dbname); // aantal per page $num_rec_per_page=30; //check connection if ($conn->connect_error) { die("connection failed:" . $conn->connect_error); } if (isset($_get["page"])) { $page  = $_get["page"]; } else { $page=1; };  $start_from = ($page-1) * $num_rec_per_page;    $sql = "select firstname, lastname, phone, department tl_member order lastname asc limit                   30"; $result = $conn->query($sql);  if ($result->num_rows > 0) {    echo "<table><tr><br><hr><th align='left'>naam</th><th align='center'>telefoon</th><th       align='right' >afdeling</th></tr>"; // output data in rows while($row = $result->fetch_assoc()) {        echo "<tr><td align='left'>" .$row["firstname"].", " .$row["lastname"]."</td><td   align='center'>". $row["phone"]."</td><td align='right'>". $row["department"]."</td></tr>";  }                echo "</table>";     } else { echo "0 results"; } $sql = "select * tl_member"; $rs_result = mysqli_query($sql); //run query $total_records = mysqli_num_rows($rs_result);  //count number of records $total_pages = ceil($total_records / $num_rec_per_page);   echo "<a href='pagination.php?page=-1'>".'|<'."</a> "; // goto 1st page    ($i=1; $i<=$total_pages; $i++) {          echo "<a href='pagination.php?page=".$i."'>".$i."</a> ";  };  echo "<a href='pagination.php?page=$total_pages'>".'>|'."</a> "; // goto last page  $conn->close(); ?> 

the errors :

warning: mysqli_query() expects @ least 2 parameters, 1 given in c:\xampp\htdocs\new\pagination.php on line 56

warning: mysqli_num_rows() expects parameter 1 mysqli_result, null given in c:\xampp\htdocs\new\pagination.php on line 57

i have no clue doing wrong.

from php reference:

mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = mysqli_store_result ] ) 

the first argument should mysqli resourcelink, second query;

$rs_result = mysqli_query($conn, $sql); //run query 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -