how can i get into a variable the number of rows in a table? 
list number of rows in a table
| alalex wrote: |
| how can i get into a variable the number of rows in a table? |
Well ... if the table has 42 rows just do
| Code: |
| $a_variable = 42; |
Just kidding
try
| Code: |
| $sql = 'select count(*) from a_table';
$res = mysql_query($sql) or die('query error on line ' . __LINE__ . ': ' . mysql_error()); $a_variable = mysql_result($res, 0, 0); mysql_free_result($res); |
thanks
Depending on the version of PHP or MySQL support you have, this might also work:
This is the way that works for my setup, it may be different depending on how you have PHP and your MySQL extensions set up.
| Code: |
| $say = 'select * from table';
$answer = mysql_query($say) or die('Query failed: '.mysql_error()); $rows = mysql_numrows($answer); |
This is the way that works for my setup, it may be different depending on how you have PHP and your MySQL extensions set up.
| jeremyw wrote: |
| ... |
http://www.frihost.com/forums/vp-508437.html#508437
Yeah
. I've been wanting to use this image for ages ...
-close-
-close-
