-2

I have a page where users can add new input fields, such as

<input class="array_moment" name="MEd[]" id="MEd1" value="10" />
<textarea name="kommentar[]" id="kommentar1" value=""></textarea>

The array can have a size of up to 500, data type is float for input and varchar for textarea. The array will be stored in MySQL, but how the data should be stored.

I had intended to use json_encode () and json_decode () and store it in a single column field, but is this reasonable?

6
  • 1
    No one can answer your question, since you do not specify any details at all about what kind of data, for what purpose, what you plan to do with it.
    – arkascha
    Aug 31, 2014 at 11:12
  • The recommendation for database is generally to normalize your data unless you have very specific reasons not to do so
    – Mark Baker
    Aug 31, 2014 at 11:13
  • google 'php batch insert', that should put you on the right track
    – Tomer
    Aug 31, 2014 at 11:14
  • Do you ever need only part of the data?
    – Sumurai8
    Aug 31, 2014 at 11:20
  • you can use json or serialized data in DB.
    – Amit Garg
    Aug 31, 2014 at 11:21

1 Answer 1

0

you can try to use server side script to translate this array to sql insert statement, like this:

$arr = json_decode($_POST["column"]);

foreach($arr as $i){

$sql="insert into tmptable values({$i})";

sql_exec($sql);
}

and you can save the keys as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.