» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2005, 06:58 AM
johny johny is offline
OSP Starters
 
Join Date: Dec 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
johny is on a distinguished road
Default Counting Values in Array

Hi all
Using php with mysql. I have table_one and column_something that is enum type with the values "A", "B" and "C". I would like to count these values and then echo how many there are of each of these individual values from column_something. I'm confused about this. This is how I am going about it but can't finish.

It comes as::
Parse error: parse error, unexpected T_DNUMBER, expecting T_VARIABLE or '$' -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 12-07-2005, 07:00 AM
jami jami is offline
OSP Starters
 
Join Date: Dec 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
jami is on a distinguished road
Default PHP Code

The following is the solution for it:

PHP Code
while($row = mysql_fetch_array($result)){
$vals[$row['column_something']] = $row['count'];
}

foreach($vals as $var => $val)
{
echo $var.' => '.$val.'<br>';
} -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
timestamp values Wumchi MySQL Forums 1 03-11-2007 07:33 AM
way to merge Hash (Array) dynamically? benaud PHP Programming and Tips 2 08-11-2006 01:21 PM
retrieve multiple values parrod ASP forums and Tips 1 08-10-2006 02:11 PM
Welcome to array on OutSourcingPlans... osp Introductions 0 07-18-2006 02:22 PM
Unable to Assign in an Array !! jackky PHP Programming and Tips 1 12-09-2005 05:03 AM


All times are GMT. The time now is 10:30 AM.