Jump to content

simple checklist form question


Recommended Posts

Hi,

 

I'm writing a simple checklist for monitoring workflow. It will be a form, a list of tasks with radio buttons that return '0' or '1'.

 

I'm planning to store the results in a MySql db, i'm just wondering what the best way to do this is.

 

My initial thoughts are to store the results as a string in one field in the db (like '11100100010' etc) and then split that out to feed the form using LEFT in the query (LEFT(Field, 3) as 'Job 3' or something like that).

 

If that is a sensible way to do it - how do I go about creating the string from the 'submit', i mean, i understand how to update the DB, thats fine - I'm just not to sure how to create a string from several form elements??

Link to comment
https://forums.phpfreaks.com/topic/200988-simple-checklist-form-question/
Share on other sites

The question of using one or many fields depends on the number of inputs you have.  Also remember that if you use one field, then for every query against the database you have to run some extra processing to get the result extracted.

 

Personally, i would use separate fields for each one.

 

To create a string from submit, you assign the posted variables to a variable in your action script

$var1 = $_POST['var1'];
$var1 = $_POST['var1'];

 

and to string them together, if you want to use 1 table field

 

$string = $var1.$var2....

ah ok, so its more efficient to have a database with sat 100 fields, each containing 1 or 0 than to have one field with a string of 100 chars.

 

Ok, in that case its I dont need to concatenate the form results.

 

Thanks!!

 

Remember, I said that it depends on how many fields you have.  You can try either way to see if it makes a difference in performance.

 

 

Simply, you 2 choices for a select are

 

With 1 field

- Select field from table.

-  run string function to locate and extract one of multiples values

 

With multiple fields

- Select fields from table

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.