FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


mysql/php help please





golles
how can I via a php command look how much tings are in a table?
Someone gave me a cool script and it is running fine now Smile but I want to show somewhere: "there are X users in the ranktracker.".
script: www.golles.frihost.net/KoC/TDO/ranks

I think it can easely be done by just looking how much rows there are in that table, but I'm not formiliar with mysql.
here is a screenshot of the database:

Hope someone can help me?


//golles
dandelion
It seems really simple task. Wink
(It counts number of rows in the ranktracker table)
Code:
<?
  $query = 'SELECT COUNT(*) FROM ranktracker';
  $result = mysql_query($query);
  $X = mysql_result($result, 0);
  echo "there are $X users in the ranktracker."
?>

or
Code:
<?
  $query = 'SELECT * FROM ranktracker';
  $result = mysql_query($query);
  $X = mysql_num_rows($result);
  echo "there are $X users in the ranktracker."
?>
golles
thanks I got it working now Very Happy Very Happy Very Happy
Code:
<?
  $query = 'SELECT * FROM ranks_static';
  $result = mysql_query($query);
  $X = mysql_num_rows($result);
  echo "there are $X users in the ranktracker."
?>


I had to change ranktracker to ranks_static


//golles
bladercity
dandelion wrote:
It seems really simple task. Wink
(It counts number of rows in the ranktracker table)
Code:
<?
  $query = 'SELECT COUNT(*) FROM ranktracker';
  $result = mysql_query($query);
  $X = mysql_result($result, 0);
  echo "there are $X users in the ranktracker."
?>

or
Code:
<?
  $query = 'SELECT * FROM ranktracker';
  $result = mysql_query($query);
  $X = mysql_num_rows($result);
  echo "there are $X users in the ranktracker."
?>


Really easy Smile
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.