Jump to content

[SOLVED] Getting the number of rows


chantown

Recommended Posts

Hi,

 

Let's say i have a query:

 

"SELECT topic_name FROM mytable WHERE user='$username' LIMIT $Start, $pageSize";

 

Now i can display the topic_name in a table.

 

However, I want to know how many TOTAL topics there are from this user, so I can make pages and calculate how many topics on each page (pagination)

 

How do I do that without using another query like this?--

"SELECT count(topic_name) FROM mytable WHERE user = '$username'";

 

:) fank you

Link to comment
https://forums.phpfreaks.com/topic/79048-solved-getting-the-number-of-rows/
Share on other sites

See if you are doing for pagination then you need 2 queries for e.g.

First

query = SELECT topic_name FROM mytable WHERE user='$username';

numrows = mysql_numrows(query)

 

here you will get total rows for pagination purpose, then you add the limit again

new_query = query."LIMIT $Start, $pageSize";

result = mysql_query(new_query)

 

And you will get the limit from here and total rows from above. Hope you got the idea

Tell me if I am wrong...

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.