is this code correct? but i got this error message 'Resource id #2'
<?
$Connect = mysql_connect("localhost","root","");
mysql_select_db("mw");
$result=mysql_query("select count(StaffID) from LeaveApplication1 where StaffID = 'fui'") ;
echo "$result";
mysql_close();
?>
count
Moderator: General Moderators
The value of $result is a pointer to your result set returned from your query, you will need a few extra steps to get the data out of your table.
Depending on the amount of data return you will need to use either:
mysql_fetch_row() :
http://uk2.php.net/manual/en/function.m ... ch-row.php
or
mysql_fetch_array() :
http://uk2.php.net/manual/en/function.m ... -array.php
There are other methods that you can use, but these are the nost common and should return what you need.
Regards,
Depending on the amount of data return you will need to use either:
mysql_fetch_row() :
http://uk2.php.net/manual/en/function.m ... ch-row.php
or
mysql_fetch_array() :
http://uk2.php.net/manual/en/function.m ... -array.php
Code: Select all
<?
$Connect = mysql_connect("localhost","root","");
mysql_select_db("mw");
$result = mysql_query("select count(StaffID) from LeaveApplication1 where StaffID = 'fui'") ;
$row = mysql_fetch_row($result)
var_dump($row);
mysql_close();
?>Regards,