query php pagination jquery

I have this sql command that gives me result from search

$query = mysql_query("SELECT * FROM persons WHERE FirstName LIKE '%" . $searchText . "%' ORDER by RAND() LIMIT $offset,$per_page");

can anyone teach me if i can get the number of result so that i can replace the value of pagination this is the value of pagination so it only counts the whole table and numbers of rows.

$count_query = mysql_query("SELECT COUNT(personid) AS numrows FROM persons");

I know it will only count all of the rows so it gives me all the result in numbers. I want to the query so that it will only count the result when I press enter from my search it is in jquery . can i assign a query that will count the $query variable rows result?

Upvotes: 0

Views: 410

Answers (1)

Guanxi
Guanxi

Reputation: 3131

What I am getting from your question is that you are trying to count the number of rows returned by first query in $query variable.

$num_rows = mysql_num_rows($query);

This should help you.

Upvotes: 3

Related Questions