vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Checkboxes -> Database (https://vborg.vbsupport.ru/showthread.php?t=77534)

Adrian Schneider 03-05-2005 03:34 PM

Checkboxes -> Database
 
How would I go about doing this:

Insert checked checkboxes into database as a set (into text field), the only complication is the # of checkboxes is an unknown, as there is one for every 'player' in the player table (values are IDs). The names of the fields all are: positionXXX (where XXX = playeriD).

Sorry if this is yet another easy question, my brain shuts off sometimes. :rolleyes:

Marco van Herwaarden 03-05-2005 04:31 PM

You should name your fields as an array ie position[].

Then you can just serialize the array into the database field.

Adrian Schneider 03-05-2005 04:39 PM

Okay, I set them as position[$id], what do you mean by serialize the array?

Marco van Herwaarden 03-05-2005 04:47 PM

PHP Code:

serialize($position


Adrian Schneider 03-05-2005 05:11 PM

Could someone elaborate on this a little for me. Do I create the array first? and do I name them $position[$id] or just position[$id] (if position[$id] how does it know what $position is?)

Marco van Herwaarden 03-05-2005 05:19 PM

You name the field in your form 'position[]' (or 'position[$id]' if the Id is relevant).

After submit your would do a:

PHP Code:

    globalize($_POST, array(
    
'position'
    
));
.
.
.
<
insert/update database>
     
serialize($position


Adrian Schneider 03-05-2005 06:42 PM

Thanks for all the help so far.

2 small problems (I hope): I have a select menu of all the players, I want to restrict the players by only showing results where FIND_IN_SET('$id', fieldname) but I need the $id to be the current $id that mysql is processing, the other problem is, if the id is 1, 11, 21, 108, and 3081, all of these will be included. Is there a way to force X # of digits?

If this makes the first problem easier, the field containing the string of numbers (ex: 1,3,4,25,234234,3563) is in another table, which is selected prior to all of this.

Marco van Herwaarden 03-05-2005 07:52 PM

Sorry you lost me now.


All times are GMT. The time now is 10:06 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.01115 seconds
  • Memory Usage 1,722KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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