title: How to pagination in mysql php
body: <p>I have a script of pagination. When I run, it show the following error:</p>
  
  <pre><code>Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\folder\index.php on line 6
  
  Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\folder\index.php on line 12
  </code></pre>
  
  <p>Here's my script:</p>
  
  <pre><code>&lt;?php
  include 'db.inc.php';
  $per_page = 2;
  
  $pages_query = mysql_query("SELECT COUNT 'id' FROM 'names'");
  $pages = ceil(mysql_result($pages_query,0) /$per_page);
  
  $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
  $start = ($page - 1) * $per_page;
  
  $query = mysql_query("SELECT 'name' FROM 'names' LIMIT $start, $per_page");
  while ($query_row = mysql_fetch_assoc($query)) {
  echo '&lt;p&gt;', $query_row['name'],'&lt;/p&gt;';
  }
  if($pages &gt;=1 &amp;&amp; $page &lt;= $pages){
  for ($x=1; $x&lt;=$pages; $x++){
  echo  ($x == $page) ? '&lt;strong&gt; &lt;a href="?page='.$X.'"&gt;'.$x.'&lt;/a&gt;&lt;/strong&gt; ' : '&lt;a href="?page='.$X.'"&gt;'.$x.'&lt;/a&gt; ';
  }
  }
  ?&gt;
  </code></pre>
  
  <p>At last i found my problem. It was for $X.
  The correct is:</p>
  
  <pre><code>echo  ($number == $page) ? '&lt;strong&gt; &lt;a href="?page='.$number.'"&gt;'.$number.'&lt;/a&gt;&lt;/strong&gt; ' : '&lt;a href="?page='.$number.'"&gt;'.$number.'&lt;/a&gt; ';
  </code></pre>