Jump to content

Insert data from list


Darkmatter5

Recommended Posts

I have a text box, a list that's generated by a query and a submit button.  I know how to submit the data entered from the text box into the table, but now do I reference the data selected from the list.

 

Here's the insert code I use.

<?php

      if(isset($_POST['addsurvey']))

    {

    include 'library/dbconfig.php';

    include 'library/opendb.php';

   

    $Survey=$_POST['Survey'];

    $SurvCounty=$_POST['SurvCounty'];

   

    //put new type data from form into the types table

    $insertdata="INSERT INTO byrnjobdb.surveys (Survey, SurvCounty) VALUES ('$Survey', '$SurvCounty')";

    mysql_query($insertdata) or die('Error, insert query failed');

   

    //after new survey data is applied to surveys table, display success message

    echo "New Survey ADDED...";

   

    include 'library/closedb.php';

    }

    else

    {}

    ?>

 

And here's the code I have to construct the list.

<?php

        include 'library/dbconfig.php';

      include 'library/opendb.php';

     

      $query=mysql_query(sprintf("SELECT County FROM byrnjobdb.counties ORDER BY County ASC"));

      echo "<select name='SurvCounty'>";

      while ($result=mysql_fetch_assoc($query))

      {

      $r=$result['County'];

      echo "<option value='$r'>$r</option>";

      }

      echo "</select>";

     

      include 'library/closedb.php';

    ?>

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/102768-insert-data-from-list/
Share on other sites

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.