PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP 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:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 27th, 2004, 04:40 PM
dotty dotty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 7 dotty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Help! I need to write multi-selection form data into field?

Hi,

I have a database and one of the fields is populated by a multi-selection form field, in this case, checkboxes. I've named all the checkboxes the same name as the field and allocated different values to each but only the first checkbox value shows up in the database. Is there some trick here? Do I need a separate field for each? I would just like to have them listed in the database.

Thanks to anybody who can help me!


Reply With Quote
  #2  
Old May 27th, 2004, 07:32 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Add a pair of squarebrackets to the end of your field name in the HTML form - when that field is returned to your script, you'll be able to access the field values as an array. Yes, it's a dodgy hack, but it's the only way PHP can do it.

More info: http://academ.hvcc.edu/~kantopet/ph...php+client+side
"Form field names" section

Reply With Quote
  #3  
Old May 28th, 2004, 03:03 AM
dotty dotty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 7 dotty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Stumpy. I will try that!

Reply With Quote
  #4  
Old May 28th, 2004, 09:37 AM
dotty dotty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 7 dotty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Stumpy - Okay - so I've added the square brackets and been to your site and it all seems to make sense, until I run the script and I keep getting parse error. I did this with Dreamweaver MX so maybe the script is slightly different:

This is the original code to extract checkbox data from a form with checkboxes named 'interests[]' with values: Business, Entertainment and Finance

PHP Code:
 GetSQLValueString($HTTP_POST_VARS['interests'], "text"), 


Does the array go in like this?

PHP Code:
 GetSQLValueString($HTTP_POST_VARS['interests'], (Business","Entertainment","Finance"), "text"), 


or this?

PHP Code:
 GetSQLValueString($HTTP_POST_VARS['interests'], ['Business','Entertainment','Finance'], "text"), 


whatever combination I use brings up a parse error.

On you site you wrote

Quote:
... or by assigning the element value to another array and accessing that.
PHP Code:
 $field1Arr $_POST["field1"];$firstVal $field1Var[0]; 

Where would this code go? After or within the first line? I just don't know how to apply your code to mine because I don't have enough experience with PHP code I'd appreciate any assistance!

Thanks in advance!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help! I need to write multi-selection form data into field?


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 | 
  
 





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