Note that there are some explanatory texts on larger screens.

plurals
  1. POForm Not Populating in SQL Database
    text
    copied!<p>I am trying to populate some data from a php form into a sql database when the user selects submit. However, the 'animalClass' and 'animalCommon' data is not populating; however the other data is populating fine. First I will post the HTML/PHP code and then some screen shots of the SQL db. Thank you for looking and the assistance.</p> <pre><code>$db = get_db_connection('swcrc'); $db-&gt;connect(); //Process status update form if submitted if(isset($_GET['admin_update']) &amp;&amp; isset($_POST['request_id']) &amp;&amp; isset($_POST['status']) &amp;&amp; $_POST['status'] != '') { $db-&gt;query("UPDATE dbo.Request SET status='%s' WHERE ID=%d", $_POST['status'], $_POST['request_id']); $db-&gt;query("INSERT INTO dbo.Response (request_ID, user_ID, complete, comment, response_date, animalClass, animalCommon) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s')", $_POST['request_id'], $_POST['status_update_user_id'], $_POST['status'], $_POST['status_update_comments'], $_POST['date_completed'], $_POST['animalClass'], $_POST['animalCommon']); $msgs = "Status updated successfully."; $mode = "readonly"; } //Process admin update form if submitted else if(isset($_POST['request_id']) &amp;&amp; isset($_POST['completed']) &amp;&amp; $_POST['completed'] != '') { $db-&gt;query("UPDATE dbo.Request SET status='%s' WHERE ID=%d", $_POST['completed'], $_POST['request_id']); $db-&gt;query("INSERT INTO dbo.Response (request_ID, user_ID, complete, comment, response_date, animalClass, animalCommon) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s')", $_POST['request_id'], $_POST['completed_by_user_id'], $_POST['completed'], $_POST['not_completed'], $_POST['date_completed'], $_POST['animalClass'], $_POST['animalCommon']); $msgs = "Details updated successfully."; </code></pre> <p>Next I will post the select statement code:</p> <pre><code>&lt;p&gt; &lt;label for="animalClass"&gt;Class&lt;/label&gt; &lt;select id = "animalClass" name="animalClass"&gt; &lt;option&gt;Select a Class:&lt;/option&gt; &lt;option value="Amphibians"&gt;Amphibians&lt;/option&gt; &lt;option value="Birds"&gt;Birds&lt;/option&gt; &lt;option value="Cnidarians"&gt;Cnidarians&lt;/option&gt; &lt;option value="Fish"&gt;Fish&lt;/option&gt; &lt;option value="Invertebrates"&gt;Invertebrates&lt;/option&gt; &lt;option value="Mammals"&gt;Mammals&lt;/option&gt; &lt;option value="Reptiles"&gt;Reptiles&lt;/option&gt; &lt;/select&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="animalCommon"&gt;Common Name&lt;/label&gt; &lt;select name="animalCommon" id="animalCommon"&gt; &lt;option&gt;Select a Common Name:&lt;/option&gt; &lt;?php $db = get_db_connection('swcrc'); $db-&gt;connect(); $db-&gt;query("SELECT [Common Name] FROM dbo.All_Animals"); while($row = $db-&gt;fetch()) { ?&gt; &lt;option value="&lt;?php echo $row['ID'];?&gt;"&gt;&lt;?php echo $row['Common Name'];?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="animalScientific"&gt;Scientific Name&lt;/label&gt; &lt;select name="animalScientific" id="animalScientific"&gt; &lt;option&gt;Select a Scientific Name:&lt;/option&gt; &lt;?php $db = get_db_connection('swcrc'); $db-&gt;connect(); $db-&gt;query("SELECT [Scientific Name] FROM dbo.All_Animals"); while($row = $db-&gt;fetch()) { ?&gt; &lt;option value="&lt;?php echo $row['ID'];?&gt;"&gt;&lt;?php echo $row['Scientific Name'];?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;/p&gt; </code></pre> <p>And finally here is a snap shot of my results in my sql database. Thank you again for looking and hopefully answering. The issue that you will see in the picture is the empty spaces where the selected data should be populated. <img src="https://i.stack.imgur.com/H9uKM.jpg" alt="As you can see, nothing is populating the the third and second to last columns."></p> <p><img src="https://i.stack.imgur.com/X5AnL.jpg" alt="Form"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload