I have created a function for counting the rows in a mysql table as follows:
Code: Select all
<?php
include 'connect.php';
function my_count($table)
{
echo $table;
$query = "SELECT COUNT(*) FROM $table";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
$count = $row['COUNT(*)'];
}
echo $count;
return $count;
}
echo my_count(sectors);
?>
Code: Select all
<?php
include 'connect.php';
include 'count.php';
$count = my_count(sectors);
echo $count;
?>
I know that I dont need to use my_count() in the first file, it was just to test it