4 Replies - 2282 Views - Last Post: 13 December 2007 - 10:58 PM Rate Topic: -----

#1 zachary  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-November 07

outputing 10 row per page

Posted 23 November 2007 - 09:25 AM

i have tried running the script below but theirs is a problem please if you can assist to refining the script to make it function .
iwas trying to output the rows of results 10 rows per page but the script has a problem at the place with '*'.
<?php
mysql_connect("localhost","root",""); //(mysql server, username, password)

mysql_select_db("maxtor") or die("Can not find database"); //mydatabase, maxtor etc ...
  if (empty($page)) {
	  $s=0;
  }
  else
  {
 $s = $page;
  }

// SQL Query with limiting results
// 10 results will be displayed in each page
$limitQuery = 10; 
$query = "select userid, first_name, age,gender,course,nationality,historyfrom admission LIMIT $s, $limitQuery";


 $numresults=mysql_query($query);
 *$numrows = mysql_num_rows($numresults);//where the problem is



if ($numrows == 0)
  {
  echo "<h4>There is no any news found .... </h4>";

  }


  $result = mysql_query($query) or die("SQL Query failed ...");



$count = 1 + $s;


  while ($row= mysql_fetch_array($result)) {
  $title = $row["userid"];
  $newsID = $row["first_tname"];
  echo "<h1><a href=\"read.php?id=$newsID\">\"$title</a></h1>";
  echo "<br>$summary</br>";
  
  $count++;
  }

$currPage = (($s/$limitQuery) + 1);


  echo "<br />";

  if ($s>=1) { 
  $prevs=($s-$limit);
  print "&nbsp;<a href=\"$PHP_SELF?page=$prevs\">&lt;&lt; 
  Prev 10</a>&nbsp&nbsp;";
  }


  $pages=intval($numrows/$limit);


  if ($numrows%$limit) {
  $pages++;
  }

  if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

  $news=$s+$limit;

  echo "&nbsp;<a href=\"$PHP_SELF?page=$news\">Next 10 &gt;&gt;</a>";
  }

$a = $s + ($limit);
  if ($a > $numrows) { $a = $numrows; }
  $b = $s + 1;
  echo "<p>Pages $b to $a of $numrows</p>";
 
?>


Is This A Good Question/Topic? 0
  • +

Replies To: outputing 10 row per page

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: outputing 10 row per page

Posted 23 November 2007 - 09:38 AM

What's the error you're getting?
Was This Post Helpful? 0
  • +
  • -

#3 nav33n  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 02-October 07

Re: outputing 10 row per page

Posted 23 November 2007 - 11:18 AM

Its always better to print your query, go to phpmyadmin, execute the query and check the output.

Quote

$numrows = mysql_num_rows($numresults);

Here, I believe, $numresults isnt a valid result resource. Try this.
$numrows = mysql_num_rows($numresults) or die(mysql_error()); 

Was This Post Helpful? 0
  • +
  • -

#4 _net  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 147
  • Joined: 23-September 07

Re: outputing 10 row per page

Posted 29 November 2007 - 12:08 PM


$query = "select userid, first_name, age,gender,course,nationality,historyfrom admission LIMIT $s, $limitQuery";



See the query, you have the keyword FROM attached to history.

This post has been edited by _net: 29 November 2007 - 12:09 PM

Was This Post Helpful? 0
  • +
  • -

#5 TheKing  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-December 07

Re: outputing 10 row per page

Posted 13 December 2007 - 10:58 PM

[mod edit] We don't give out complete solutions like that.

This post has been edited by snoj: 13 December 2007 - 11:06 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1