Hello
ok this code below,
These are three different SQL sentences to get the total number of records:
SELECT COUNT(*) FROM test_table;
SELECT COUNT(id) FROM test_table;
SELECT COUNT(1) FROM test_table;
now how do i get that total number of records from mysql and store that into php variable?
thank you in advance.
use mysql_fetch_assoc()
then use print_r() to see the answer
Heres an example:
mysql_connect("localhost","user","password");
mysql_select_db("dbname");
$q = mysql_query("SELECT COUNT(*) as COUNTALL FROM test_table");
while($result=mysql_fetch_array($q)){
$count = $result['COUNTALL'];
}
echo $count;
sajan
4
use
while($result=mysql_fetch_array($q)){
$count = $result[‘COUNTALL’];
}
list($count) = mysql_fetch_array($q);