Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Answer to #1:</strong></p> <p>You can use Javascript/AJAX to accomplish submitting the form without actually pressing submit. There are various javascript libraries that can help you accomplish this a lot easier than bare bones Javascript, namely jQuery ( <a href="http://jquery.com/" rel="nofollow">http://jquery.com/</a> ). It's not a very complicated task but you will need to learn some basic Javascript and how to use jQuery. The essential flow of things would be <em>when the form changes, submit an AJAX request to submit the form</em>. You will need a second script to take the incoming AJAX request and do the save. Try search engines for some basic jQuery tutorials, and once you have a basic grip, something like "ajax submit on form change jquery" will get you started. </p> <p><strong>Answer to #2:</strong> </p> <p>Something like this (please see my notes...)</p> <pre><code>echo '&lt;select name="rating" id="rating"&gt;'; $q = mysql_query("SELECT `option_name` FROM `options`"); while($row = mysql_fetch_assoc($q)) { echo '&lt;option value="' . $row['option_name'] . '"&gt;' . $row['option_name'] . '&lt;/option&gt;'; } echo '&lt;/select&gt;'; </code></pre> <p>If you would like the select preselected, that's pretty easy too! Taking from the last example:</p> <pre><code>$pre_selected = "Very Bad"; echo '&lt;select name="rating" id="rating"&gt;'; $q = mysql_query("SELECT `option_name` FROM `options`"); while($row = mysql_fetch_assoc($q)) { echo '&lt;option value="' . $row['option_name'] . '"'; if($row['option_name'] == $pre_selected) { echo ' selected="selected"'; } echo '&gt;' . $row['option_name'] . '&lt;/option&gt;'; } echo '&lt;/select&gt;'; </code></pre> <p>But this is the part I'd like to point a few things out:</p> <ul> <li>Don't use the old mySQL library like you are using and my examples are using. Please, use PDO, or at least mySQLi. The functions you are using are deprecated, and may not be available in PHP for much longer.</li> <li>Please, escape your data properly. Search for "SQL Injection" and you will find a massive amount of information about how your code is <em>very</em> insecure (your UPDATE, specifically) because you did not escape the values. </li> <li>Just a heads up, when/if you use jQuery, you're going to need to use <code>id="foo"</code> in addition to <code>name="foo"</code>. </li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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