vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Process multiple checkboxes into a Database (https://vborg.vbsupport.ru/showthread.php?t=106911)

Red Blaze 02-01-2006 07:03 PM

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.

matthepepe 02-02-2006 05:20 PM

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

Red Blaze 02-02-2006 08:29 PM

1 Attachment(s)
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?

Red Blaze 02-06-2006 03:33 PM

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


All times are GMT. The time now is 02:39 AM.

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.01000 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete