Jump to content

PHP quiz form to many inputs


dsp77

Recommended Posts

Hello,

 

I have a quiz to make with approximate 500 input boxes that i need to record in the data base, i am able to make them i use $question1=$_POST['question1']; $query="INSERT INTO quiz question1 VALUES $question1; etc. but there are to many i'm sure that is a better way not to write so many lines. Please guide me finding a better practice.

Link to comment
Share on other sites

i have only tables like this

      <table id="tabela1" cellspacing="0" cellpadding="0">
        <tr>
          <td align="center"><strong>Date</strong></td>
          <td align="center"><strong>Anul universitar 2004/2005</strong></td>
          <td align="center"><strong>Anul universitar 2008/2009</strong></td>
        </tr>
        <tr>
          <td>a. nume şi prenume</td>
          <td align="center"><input name="3_an0405_a" type="checkbox" id="3_an0405_a" value="1" /></td>
          <td align="center"><input name="3_an0809_a" type="checkbox" id="3_an0809_a" value="1" /></td>
        </tr>
        <tr>
          <td>b. sex
          </p></td>
          <td align="center"><input name="3_an0405_b" type="checkbox" id="3_an0405_b" value="1" /></td>
          <td align="center"><input name="3_an0809_b" type="checkbox" id="3_an0809_b" value="1" /></td>
        </tr>
        <tr>
          <td>c. naţionalitate</td>
          <td align="center"><input name="3_an0405_c" type="checkbox" id="3_an0405_c" value="1" /></td>
          <td align="center"><input name="3_an0809_c" type="checkbox" id="3_an0809_c" value="1" /></td>
        </tr>
        <tr>
          <td>d. domiciliu stabil</td>
          <td align="center"><input name="3_an0405_d" type="checkbox" id="3_an0405_d" value="1" /></td>
          <td align="center"><input name="3_an0809_d" type="checkbox" id="3_an0809_d" value="1" /></td>
        </tr>
        <tr>
          <td>e. număr telefon fix</td>
          <td align="center"><input name="3_an0405_e" type="checkbox" id="3_an0405_e" value="1" /></td>
          <td align="center"><input name="3_an0809_e" type="checkbox" id="3_an0809_e" value="1" /></td>
        </tr>
        <tr>
          <td>f. număr telefon mobil</td>
          <td align="center"><input name="3_an0405_f" type="checkbox" id="3_an0405_f" value="1" /></td>
          <td align="center"><input name="3_an0809_f" type="checkbox" id="3_an0809_f" value="1" /></td>
        </tr>
        <tr>
          <td>g. adresă e-mail</td>
          <td align="center"><input name="3_an0405_g" type="checkbox" id="3_an0405_g" value="1" /></td>
          <td align="center"><input name="3_an0809_g" type="checkbox" id="3_an0809_g" value="1" /></td>
        </tr>
        <tr>
          <td>h. facultatea absolvită</td>
          <td align="center"><input name="3_an0405_h" type="checkbox" id="3_an0405_h" value="1" /></td>
          <td align="center"><input name="3_an0809_h" type="checkbox" id="3_an0809_h" value="1" /></td>
        </tr>
        <tr>
          <td>i. domeniul de studiu</td>
          <td align="center"><input name="3_an0405_i" type="checkbox" id="3_an0405_i" value="1" /></td>
          <td align="center"><input name="3_an0809_i" type="checkbox" id="3_an0809_i" value="1" /></td>
        </tr>
        <tr>
          <td>j. media de absolvire</td>
          <td align="center"><input name="3_an0405_j" type="checkbox" id="3_an0405_j" value="1" /></td>
          <td align="center"><input name="3_an0809_j" type="checkbox" id="3_an0809_j" value="1" /></td>
        </tr>
        <tr>
          <td>k. alte date care nu sunt înscrise în baza de date, dar sunt trecute în alte documente</td>
          <td><textarea style="width:220px;" name="3_an0405_k" id="3_an0405_k"></textarea></td>
          <td><textarea style="width:220px;" name="3_an0809_k" id="3_an0809_k"></textarea></td>
        </tr>
      </table>

$3_an0405_a=$_POST['3_an0405_a'];
$3_an0405_b=$_POST['3_an0405_b'];
$3_an0405_c=$_POST['3_an0405_c'];
$3_an0405_d=$_POST['3_an0405_d'];
$3_an0405_e=$_POST['3_an0405_e'];
$3_an0405_f=$_POST['3_an0405_f'];
$3_an0405_g=$_POST['3_an0405_g'];
$3_an0405_h=$_POST['3_an0405_h'];
$3_an0405_i=$_POST['3_an0405_i'];
$3_an0405_j=$_POST['3_an0405_j'];
$3_an0405_k=$_POST['3_an0405_k'];
$3_an0809_a=$_POST['3_an0809_a'];
$3_an0809_b=$_POST['3_an0809_b'];
$3_an0809_c=$_POST['3_an0809_c'];
$3_an0809_d=$_POST['3_an0809_d'];
$3_an0809_e=$_POST['3_an0809_e'];
$3_an0809_f=$_POST['3_an0809_f'];
$3_an0809_g=$_POST['3_an0809_g'];
$3_an0809_h=$_POST['3_an0809_h'];
$3_an0809_i=$_POST['3_an0809_i'];
$3_an0809_j=$_POST['3_an0809_j'];
$3_an0809_k=$_POST['3_an0809_k'];
$query="INSERT INTO tabela1 (	 3_an0405_a,
						 3_an0405_b,
						 3_an0405_c,
						 3_an0405_d,
						 3_an0405_e,
						 3_an0405_f,
						 3_an0405_g,
						 3_an0405_h,
						 3_an0405_i,
						 3_an0405_j,
						 3_an0405_k,
						 3_an0809_a,
						 3_an0809_b,
						 3_an0809_c,
						 3_an0809_d,
						 3_an0809_e,
						 3_an0809_f,
						 3_an0809_g,
						 3_an0809_h,
						 3_an0809_i,
						 3_an0809_j,
						 3_an0809_k) 
	VALUES ('	'$3_an0405_a',
			'$3_an0405_b',
			'$3_an0405_c',
			'$3_an0405_d',
			'$3_an0405_e',
			'$3_an0405_f',
			'$3_an0405_g',
			'$3_an0405_h',
			'$3_an0405_i',
			'$3_an0405_j',
			'$3_an0405_k',
			'$3_an0808_a',
			'$3_an0808_b',
			'$3_an0808_c',
			'$3_an0808_d',
			'$3_an0808_e',
			'$3_an0808_f',
			'$3_an0808_g',
			'$3_an0808_h',
			'$3_an0808_i',
			'$3_an0808_j',
			'$3_an0808_k',)";

the questions are static and the answer can be check box or input text. as u can see a part from the quiz its kinda long.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.