Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2006, 07:03 PM
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Location: Texas
Posts: 493
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Process multiple checkboxes into a Database

I'm making a survey and I have 3 questions that can have multiple choices selected. But when I submit the survey, only the last one selected in each question's item chosen gets stored in the database. I tried figuring this out on my own all day and my brain is so fried. Any help or leads would be greatly appreciated. Thanks.
Reply With Quote
  #2  
Old 02-02-2006, 05:20 PM
matthepepe matthepepe is offline
 
Join Date: Jan 2002
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

add [] to the field name in your form.... just as if you were building an array,

then once its submitted they are stored as an array
Reply With Quote
  #3  
Old 02-02-2006, 08:29 PM
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Location: Texas
Posts: 493
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's what I did now.

Code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "OrderForm")) {
 $value_array = $_POST['intend'];
foreach($value_array as $value){
  $intend .= $value; 
}
 $value_array = $_POST['favorlook'];
foreach($value_array as $value){
 $favorlook .= $value; 
}
 $value_array = $_POST['elements'];
foreach($value_array as $value){
 $elements .= $value; 
}
  $insertSQL = sprintf("INSERT INTO orders (customer, company, address, city, `state`, zip, phone, email, `desc`, industry, cosize, `domain`, top1, top2, top3, hosting, HosCom, HosName, HosPhone, HosEmail, wanthost, redesign, budget, logo, nologo, market, target, pages, NetKnow, intend, favorlook, commerce, Site1, Why1, Site2, Why2, Site3, Why3, Site4, Why4, content, elements, updating, keywords, timeframe, findus, addinfo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['customer'], "text"),
                       GetSQLValueString($_POST['company'], "text"),
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['zip'], "text"),
                       GetSQLValueString($_POST['phone'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['desc'], "text"),
                       GetSQLValueString($_POST['industry'], "text"),
                       GetSQLValueString($_POST['cosize'], "text"),
                       GetSQLValueString($_POST['domain'], "text"),
                       GetSQLValueString($_POST['top1'], "text"),
                       GetSQLValueString($_POST['top2'], "text"),
                       GetSQLValueString($_POST['top3'], "text"),
                       GetSQLValueString($_POST['hosting'], "text"),
                       GetSQLValueString($_POST['HosCom'], "text"),
                       GetSQLValueString($_POST['HosName'], "text"),
                       GetSQLValueString($_POST['HosPhone'], "text"),
                       GetSQLValueString($_POST['HosEmail'], "text"),
                       GetSQLValueString($_POST['wanthost'], "text"),
                       GetSQLValueString($_POST['redesign'], "text"),
                       GetSQLValueString($_POST['budget'], "text"),
                       GetSQLValueString($_POST['logo'], "text"),
                       GetSQLValueString($_POST['nologo'], "text"),
                       GetSQLValueString($_POST['market'], "text"),
                       GetSQLValueString($_POST['target'], "text"),
                       GetSQLValueString($_POST['pages'], "text"),
                       GetSQLValueString($_POST['NetKnow'], "text"),
                       GetSQLValueString($intend, "text"),
                       GetSQLValueString($favorlook, "text"),
                       GetSQLValueString($_POST['commerce'], "text"),
                       GetSQLValueString($_POST['Site1'], "text"),
                       GetSQLValueString($_POST['Why1'], "text"),
                       GetSQLValueString($_POST['Site2'], "text"),
                       GetSQLValueString($_POST['Why2'], "text"),
                       GetSQLValueString($_POST['Site3'], "text"),
                       GetSQLValueString($_POST['Why3'], "text"),
                       GetSQLValueString($_POST['Site4'], "text"),
                       GetSQLValueString($_POST['Why4'], "text"),
                       GetSQLValueString($_POST['content'], "text"),
                       GetSQLValueString($elements, "text"),
                       GetSQLValueString($_POST['updating'], "text"),
                       GetSQLValueString($_POST['keywords'], "text"),
                       GetSQLValueString($_POST['timeframe'], "text"),
                       GetSQLValueString($_POST['findus'], "text"),
                       GetSQLValueString($_POST['addinfo'], "text"));
When I call them back, I get "Array" then the information in the table.

Here's an image.
For some reason, I get the word "Array". Anyway I can get that out?
Attached Images
File Type: jpg array.jpg (27.2 KB, 0 views)
Reply With Quote
  #4  
Old 02-06-2006, 03:33 PM
Red Blaze's Avatar
Red Blaze Red Blaze is offline
 
Join Date: Jan 2003
Location: Texas
Posts: 493
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

matthepepe, I tried what you said, and it only gave me the word array. Help?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06286 seconds
  • Memory Usage 2,217KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (1)postbit_attachment
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete