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
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...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.