General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 4th, 2003, 07:30 AM
2cents 2cents is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 2 2cents User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
array problems

I'm trying to retrieve 11 set of members record from the db. Each member will have a unique id. Thus I want to append an array like so: array( "2" => "jack", "11" => "peter" )


PHP Code:
for( $i=1$i<=11$i++ )
{
    
$array[$dbID] = $username ;



with the above code, I got


Array ( [20] => Jack )
Array ( [20] => Jack [4] => peter )
Array ( [20] => Jack [5] => may )
Array ( [20] => Jack [9] => douglas )

what I want is actually:

Array ( [20] => Jack, [4] => peter, [5] => may ...



What should I do? Thanks alot.

Reply With Quote
  #2  
Old April 4th, 2003, 11:17 AM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 17
You need to post more code before we can help you...
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #3  
Old April 5th, 2003, 03:16 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
Re: array problems

Quote:
Originally posted by 2cents
Array ( [20] => Jack )
Array ( [20] => Jack [4] => peter )
Array ( [20] => Jack [5] => may )
Array ( [20] => Jack [9] => douglas )

what I want is actually:

Array ( [20] => Jack, [4] => peter, [5] => may ...

What should I do? Thanks alot. [/B]


You are producing exactly what you wanted...
What makes you think this is not working?
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #4  
Old April 5th, 2003, 07:30 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
forgive me if i sound stupid (ive been drinking) but how do you mean array(....

are you using the print_r function to output this data?

dont forget to declair the array before you call it in your loop

eg

$array = array();

also each key MUST be unique, so ensure that the key is unique before setting it.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > array problems


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap