GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Jul-2003, 08:34
skyloon skyloon is offline
Junior Member
 
Join Date: Jun 2003
Posts: 53
skyloon is an unknown quantity at this point

count


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();
?>
  #2  
Old 23-Jul-2003, 06:49
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Use mysql_result() function for this...


$result is just a 'result resource' so it's no surprise that you get that back.

Since you asked for one 'result' expecting just a sum of all the records that matched that criteria, you can try using:

PHP Code:

<?php

$Connect = mysql_connect("localhost","root","");
mysql_select_db("mw");
$result = mysql_query( "select count(StaffID) from LeaveApplication1 where StaffID = 'fui'") ;
// echo "$result";  to be replaced by...
$total = mysql_result( $result, 0, 0 );
// the "0, 0" above is row 0 and field 0
echo $total;
mysql_close();
?>


Please look up the function mysql_result() at php.net for some important notes regarding the use of this function.
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
count date skyloon MySQL / PHP Forum 2 01-Jul-2003 02:28
FAQ - Challenger Forum JdS Learning Journal by J de Silva 0 11-May-2002 03:28

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:16.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.