Jump to content

Unable to insert into table value from dropdown list


rodlake

Recommended Posts

Hello everyone !!!

 

I am sorry if my vocabulary is not exact because english is not my first language. Also i am a newbie at PHP. I am doing this project for myself and if it work might be able to use it at work. But i am doing this to learn. I have been stuck on this problem for 2 weeks and i can t figure it out on my own. Ihave spend many hours searching forums but no success. Oh yeah i almost forgot some part of code are from me, some are scripts from internet i adapted.

 

I have a form with a dropdown menu and when i submit the form the value selected in the dropdown would be inserted in a table. The problem i have is that whatever the value i select it always inserts the last value of the dropdown in the table???

 

The form is made with the dropdown as an include. It is populated with values from an another table.

Here is the code for the dropdown list:

<form> 
   <select name="nom_pcu_form" method="post">
<?php
$SQL = "SELECT * FROM pcu ORDER BY nom_pcu";
$res = mysql_query($SQL);
while($val=mysql_fetch_array($res)) 
{
$nom=$val["nom_pcu"];
$prenom=$val["prenom_pcu"];
$nom_complet = $prenom . $nom;
echo "<option>".$val["nom_pcu"].", ".$val["prenom_pcu"]."</option>\n";

$nom_pcu_form="".$val["nom_pcu"].", ".$val["prenom_pcu"].""; 
}
?>
</select>
</form>

 

 

Here is the part of the form wich calls the dropdown:

 

<form name="form2" method="post" action="Grille ecoute Permanent.php">
              
                <p>Nom :
                 <?php include 'liste_deroulante_pcu.php' ;?> 
			<p>no carte appel
                <input name="no_carte_appel" type="text" id="no_carte_appel">
                </p>
			<?php  echo date("Y/m/d"); ?> 

 </form>

 

 

And this is the part where it is inserted in the table:

 

<?php
  if($_POST['doSubmit'] == 'Create')


  
  
  
mysql_query("INSERT INTO grille_ecoute_pcu_permanent (`user_name`,`nom_pcu`,`no_carte_appel`,`question_1`,`question_2`,`question_3`,`question_4`,
		`question_5`,`question_6`,`question_7`,`question_8`,`question_9`,`question_10`,`question_11`,`question_12`,`question_13`,`question_14`,`question_15`,
		`question_16`,`question_17`,`question_18`,`question_19`,`question_20`,`question_21`,`question_22`,`question_23`,`question_24`,`question_25`,`question_26`,
		`question_27`,`question_28`,`question_29`)
		 VALUES ('$user_name','$nom_pcu_form','$no_carte_appel','$question_1','$question_2','$question_3','$question_4','$question_5','$question_6',
		 '$question_7','$question_8','$question_9','$question_10','$question_11','$question_12','$question_13','$question_14','$question_15','$question_16','$question_17',
		 '$question_18','$question_19','$question_20','$question_21','$question_22','$question_23','$question_24','$question_25','$question_26','$question_27','$question_28',
		 '$question_29')
		 ") or die(mysql_error()); 

 

Note:$user_name and all $question are inserted correctly in the table.

$nom_pcu_form is the dropdown and it only records the last value of the dropdown even if it s not the value selected.

$no_carte_appel are not recorded at all

 

Thx for your time

 

 

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.