2016-07-06 9 views
0

私は動的にフォームフィールドを追加しましたので、DBに投稿する必要があります。ここで動的に追加されたフォームフィールドをmysqlデータベースに投稿する方法

ここでフィールド

   // set unique name for inputs 
       .find('input').each(function(index) { 
        $(this).attr('name','input_'+ tr_length + '_' + (index + 1)) 
       }) 
       .end() 
       // set unique name for selects 
       .find('select').each(function(index) { 
        $(this).attr('name','select_'+ tr_length + '_' + (index + 1)) 
       }); 

を生成jqueryのは、出力

<input type="text" name="input_2_1" /> 

<select name="select_2_1"></select> 

はあなたがDBにこれらのフィールドを投稿する私を助けてもらえです

よろしく

答えて

0

多分、このタイプのデータを扱うためのEAVテーブルを設定することをお勧めします。 EAVの例は次のようになります。..

CREATE TABLE users(
    id int not null primary key auto_increment, 
    email varchar(244) not null 
); 

CREATE TABLE user_attributes(
    id int not null primary key auto_increment, 
    user_id int not null references users(id), 
    attribute_name varchar(40) not null, 
    attribute_value varchar(200) not null 
); 

ユーザーのデータを取得する。.. SELECT *は、ユーザーからのuがa.id = ua.user_id ON user_attributes UAを登録しよう。

+0

ご返信いただきありがとうございます。私は熟練したプログラマーではないので、あまり複雑ではないソリューションを期待していました。 – Selim

関連する問題