Re: Need Help With MySQL Query
Veysel Harun Sahin wrote: select vanNumber, sum(grossPay) from usertableDaily group by vanNumber; The above is the correct query, to save yourself some time. As for your problem: But when I execute I get this: Resource id#3 Resource id#4 This means you're using a resource response from a query, not the data in the query. Don't forget to do a mysql_fetch_array or mysql_fetch_row on the resource before using it. As a test: $res = mysql_query(...); print $res; while ($row = mysql_fetch_array($res)) { print $row; print $row['id']; } -- Michael T. Babcock C.T.O., FibreSpeed Ltd. http://www.fibrespeed.net/~mbabcock - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Need Help With MySQL Query
hello, I've performed searches on this site and php.net to try and figure out why this is occuring. I can't find any instance in my searches that helped me. So, I'm posting my very first question to this list Here's my table ($usertableDaily): vanNumber|grossPay - | 1000 | 500 |100 |100 Here's my query: SELECT SUM(grossPay) FROM $usertableDaily WHERE vanNumber = $vanList[$count] The query appears inside a loop hence the $vanList[$count] variable. I have a txt file that contains the van numbers. I read that file and then run through the loop and for each van number I execute the above statement. Yes, I've trimmed off any extra blank spaces before and after the 'read' van numbers... I want to SUM the grossPay for each van number. Here's what it should be: $1500 $200 But when I execute I get this: Resource id#3 Resource id#4 Anyone got any idea why this is happening? Thanks in advance, Roger - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Need Help With MySQL Query
select vanNumber, sum(grossPay) from usertableDaily group by vanNumber; [EMAIL PROTECTED] wrote: hello, I've performed searches on this site and php.net to try and figure out why this is occuring. I can't find any instance in my searches that helped me. So, I'm posting my very first question to this list Here's my table ($usertableDaily): vanNumber|grossPay - | 1000 | 500 |100 |100 Here's my query: SELECT SUM(grossPay) FROM $usertableDaily WHERE vanNumber = $vanList[$count] The query appears inside a loop hence the $vanList[$count] variable. I have a txt file that contains the van numbers. I read that file and then run through the loop and for each van number I execute the above statement. Yes, I've trimmed off any extra blank spaces before and after the 'read' van numbers... I want to SUM the grossPay for each van number. Here's what it should be: $1500 $200 But when I execute I get this: Resource id#3 Resource id#4 Anyone got any idea why this is happening? Thanks in advance, Roger - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- Veysel Harun Sahin [EMAIL PROTECTED] - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Need Help With MySQL Query
Hi Interesting problem, normally to get a total by type, you would have a query like, select van, sum(pay) from ($usertableDaily) group by van; However you are individually quering each total, your approach is correct, but slower. The problem you have though is the return of Resource id#3 Resource id#4 So, to begin - What version of MySQL - What OS - What table type - Have you checked the table for corruption I would guess that you have some sort of table corruption. Please try repair table ($usertableDaily) and if that does fix it, email back with the rest of the data. All the best Simon On Saturday 15 February 2003 10:09 am, Guru Geek wrote: hello, I've performed searches on this site and php.net to try and figure out why this is occuring. I can't find any instance in my searches that helped me. So, I'm posting my very first question to this list Here's my table ($usertableDaily): vanNumber|grossPay - | 1000 | 500 |100 |100 Here's my query: SELECT SUM(grossPay) FROM $usertableDaily WHERE vanNumber = $vanList[$count] The query appears inside a loop hence the $vanList[$count] variable. I have a txt file that contains the van numbers. I read that file and then run through the loop and for each van number I execute the above statement. Yes, I've trimmed off any extra blank spaces before and after the 'read' van numbers... I want to SUM the grossPay for each van number. Here's what it should be: $1500 $200 But when I execute I get this: Resource id#3 Resource id#4 Anyone got any idea why this is happening? Thanks in advance, Roger - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- Simon Windsor Email: [EMAIL PROTECTED] Tel: 01454 617689 Mob: 07720 447385 - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Need Help With MySQL Query
Are you referencing the result set correctly in php ? How are you dealing with what MySQL returns ? Looks like the info is there, you just not getting it out of the result set. - Jerry @ MetalCat.Net - - Original Message - From: Guru Geek [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, February 15, 2003 10:09 AM Subject: Need Help With MySQL Query hello, I've performed searches on this site and php.net to try and figure out why this is occuring. I can't find any instance in my searches that helped me. So, I'm posting my very first question to this list Here's my table ($usertableDaily): vanNumber|grossPay - | 1000 | 500 |100 |100 Here's my query: SELECT SUM(grossPay) FROM $usertableDaily WHERE vanNumber = $vanList[$count] The query appears inside a loop hence the $vanList[$count] variable. I have a txt file that contains the van numbers. I read that file and then run through the loop and for each van number I execute the above statement. Yes, I've trimmed off any extra blank spaces before and after the 'read' van numbers... I want to SUM the grossPay for each van number. Here's what it should be: $1500 $200 But when I execute I get this: Resource id#3 Resource id#4 Anyone got any idea why this is happening? Thanks in advance, Roger - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php