Jump to content

Number of Rows in Results


dcole.ath.cx
 Share

Recommended Posts

If I have something like this:

$query  = 'SELECT message, response FROM $groupsconvert[$o]';$result = mysql_query($query);

How can I count how many rows I have? I'm trying to pick a value of a random row. I really don't want to use a while loop and count it. I think I could use:

$countresult = count(mysql_fetch_row($result));

But will that could just the current string or is that going to count the number of rows in result?

Link to comment
Share on other sites

You can use mysql_num_rows(), e.g.

$query  = 'SELECT message, response FROM $groupsconvert[$o]';$result = mysql_query($query);echo mysql_num_rows($result);

Link to comment
Share on other sites

  • 3 years later...

It's nice to do a search and find that someone else had the exact same question.

Edited by niche
Link to comment
Share on other sites

Gah, niche, you've resurrected a really old thread :). We're happy that you found a solution from the archives, but it'll continue to exist even if you don't bump it.t_closed.gif

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...