Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 3rd, 2003, 08:10 PM
clewin clewin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 clewin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Select list from array in database

Hi, I know I'm really close but the answer is eluding me at this time. I have a database with a table as such:

id|category|description|price|size_set|image|color _set

The "size_set" and "color_set" both contains arrays which determine the sizes and colors available for that item. What I have so far for code is this:

echo "<select name='color'>";
$records = explode(',', $colors);
for ( $i = '1'; $i <= count( $records ); $i++ ) {
echo "<option value=\"$records\">$records</option>";
}
echo "</select>";

But the results give me a drop down that just has the word array in it for each array item. What am I missing?

The actual page showing the results can be found at URL

Reply With Quote
  #2  
Old February 3rd, 2003, 09:20 PM
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: 6
Change ->
PHP Code:
echo "<select name='color'>";
$records explode(','$colors);
for ( 
$i '1'$i <= count$records ); $i++ ) {
echo 
"<option value=\"$records\">$records</option>";
}
echo 
"</select>"


To ->
PHP Code:
echo( '<select name="color">' );
$records explode','$colors );
for ( 
$i 0$i count$records ); $i++ ) {
echo 
'<option value="' $records[$i] . '">' $records[$i] . '<option>';
}
echo 
'</select>'
__________________
~ 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 February 4th, 2003, 02:58 AM
clewin clewin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 clewin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
select from an array

Thank you! That got me a lot closer. The only thing is now the drop down box does have the choices, but there are empty lines between each choice in the drop down box. When you click on it to display the choices they show up like this:

1

2

3

rather than:
1
2
3

Reply With Quote
  #4  
Old February 4th, 2003, 10:45 AM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
PHP Code:
 echo*'<option value="'*.*trim($records[$i])*.*'">'*.*trim($records[$i])*.*'<option>'

Reply With Quote
  #5  
Old February 4th, 2003, 04:28 PM
clewin clewin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 clewin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Still not trimming

I added the code you gave and it still didn't take out the empty lines in the select box. Any other suggestions? It's so close!

CJ Lewin

Added on at 6:28pm
Never mind! Found the problem causing the extra spaces. There was a <option> tag at the end rather than an </option> tag.

It works great now! Thanks to both of you!

CJ Lewin

Last edited by clewin : February 4th, 2003 at 05:27 PM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > Select list from array in database


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway