Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-04-2005, 05:42 PM I can't count!!!
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Hi Again,

I need help, in many ways but for this time we'll assume it's just for PHP coding. I would like to add a total of non-null fields from one field in my database on a PHP results page. Can someone help me?

The field (Named: Date_In) is a VARCHAR field but I can convert to a date type if need be. I only need to display the total amount of non-null records.

Thanks in advance.
merlin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-04-2005, 06:10 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
PHP Code:
<php
// Set up your connection first


$sql "COUNT(*) FROM mytable WHERE Date_In NOT NULL";
$query mysql_query($sql);

$res mysql_fetch_assoc($query);
echo 
$res[0];
?> 
Something about that just feels wrong though, I think I may have brainfarted on something but I'm failing to see it at the moment because I'm in a hurry.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 04-04-2005, 06:22 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Is it ' WHERE field NOT NULL' or is it 'WHERE field IS NOT NULL' ? Can't remember..., would have to check. Try both and see what happens.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-04-2005, 06:24 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
I think you just left out SELECT :

"SELECT COUNT(*) FROM mytable WHERE Date_In NOT NULL";

You could also use AS, like this:

"SELECT COUNT(*) AS Total FROM mytable WHERE Date_In NOT NULL";
__________________

Please login or register to view this content. Registration is FREE

Last edited by Phaedrus; 04-04-2005 at 06:27 PM..
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-04-2005, 06:26 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Oh yeah..... <scratches head> kinda obvious once somone points it out.... D'OH!
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-04-2005, 10:00 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
You guy's crack me up. Thanks very much, I'll try them all until one works. Thanks Again. LOL
merlin is offline
Reply With Quote
View Public Profile
 
Old 04-04-2005, 10:22 PM
HaRRo's Avatar
SEO Expert

Latest Blog Post:
The Large Hadron Collider
Posts: 522
Location: United Kingdom
Trades: 0
lol
__________________

Please login or register to view this content. Registration is FREE

What are you waiting for? Easy $$$ anyone can make a fortune!
CLICK CLICK CLICK CLICK CLICK CLICK CLICK CLICK CLICK
HaRRo is offline
Reply With Quote
View Public Profile Visit HaRRo's homepage!
 
Old 04-05-2005, 10:58 AM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Hi the coding worked but instead of getting the total I get "Resource id #7" What the heck is this????
merlin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I can't count!!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65217 seconds with 12 queries