I have created a simple form, which contains two drops down menus and a submit button. When the form is submitted the values selected in the drop down menus update a database. Is it possible to refresh the screen once the form is submitted to show these updates? At the moment I have to refresh the screen manually in order to see the updates. The code is as follows: $sql = "SELECT * FROM `Config` WHERE `CFG_ID` = '16'"; include("../includes/php/connect.php"); while ($row = mysql_fetch_assoc($rst)) { $yr9_check = $row['CFG_Value']; } $sql = "SELECT * FROM `Config` WHERE `CFG_ID` = '17'"; include("../includes/php/connect.php"); while ($row = mysql_fetch_assoc($rst)) { $yr9_type = $row['CFG_Value']; } if($yr9_check == 0) { echo "<h4>Year 9: No Subject Trawl or Internal Review has been submitted for this year group.</h4>"; } else { echo "<h4>Year 9: Currently set to <font color = '#B84340'>Check " . $yr9_check . "</font> as <font color = '#B84340'>"; if($yr9_type == "S"){echo "Subject Trawl";} elseif($yr9_type == "I"){echo "Internal Review";}"</font></h4>"; } ?> <form method = "post" action = "<?php echo $PHP_SELF;?>"> <table cellpadding="4" cellspacing="4"> <tr> <td valign="top"> <h4><font color="#000000">Set to:</h4> </td> <td valign="top"> <select name = "check"> <option value = "1">Check 1</option> <option value = "2">Check 2</option> <option value = "3">Check 3</option> <option value = "4">Check 4</option> <option value = "5">Check 5</option> <option value = "6">Check 6</option> </select> </td> <td valign="top"> <h4><font color="#000000">and</h4> </td> <td valign="top"> <select name = "type"> <option value = "S">Subject Trawl</option> <option value = "I">Internal Review</option> </select> </td> <td valign="top"> <input type = 'submit' value = 'Submit' name = 'submit' onclick = 'javascript: return confirm("Are you sure you wish to continue?")' /> <input type = 'hidden' name = 'submitted' value = 'true'> </td> </tr> </table> </form> <?php $check = $_POST['check']; $type = $_POST['type']; if (isset($_POST['check'])) { $sql2 = "UPDATE `Config` SET `CFG_Value` = '$check' WHERE `CFG_ID` = '16'"; include("../includes/php/connect2.php"); } if (isset($_POST['type'])) { $sql2 = "UPDATE `Config` SET `CFG_Value` = '$type' WHERE `CFG_ID` = '17'"; include("../includes/php/connect2.php"); } } PHP: Any help would be greatly appreciated. Regards.
Move all the code that performs the updates to the top of the script (before and of the SELECT statments), that way the database is updated before the information to be displayed is retrieved.
So should I moved everything within the POST statements above the SELECT statements as well as the form itself?
Yes, except the form can stay where it is (which is useful if you ever want to populate it with info from the SELECT statements) ... Try puttin this : At the beginning of the code you posted ...