stirrah Posted December 30, 2013 Share Posted December 30, 2013 Hello everyone! I am populating a dropdown with results from a sql query. After that I am deleting something by pressing the submit button that relates to this dropdown. The submit works and it is deleting the row in my DB, however the new result doesnt show before i reload the page. How can I make my dropdown update itself when I press submit so I can see the updated sql results? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 30, 2013 Share Posted December 30, 2013 sounds like your logic on the page is producing the dropdown before the logic that is deleting the rows in the database table. code on a page should be organized with any action/processing first, then produce and output any content. if that doesn't sound like what is causing the problem, you would need to post your code. Quote Link to comment Share on other sites More sharing options...
stirrah Posted January 1, 2014 Author Share Posted January 1, 2014 Okey, I understand what you mean. But I'm not sure how to do it any other way. This is my code: First I fetch users from DB: $usersquery = mysql_query("SELECT * blablabla)"); while($row = mysql_fetch_array($usersquery)) { $users .="<option value=\"".$row['user_id']."\">" . $row['username'] . "</option>"; } Then I show them in a dropdown / add submit button: <?php echo $users ?> </select> <input type="submit" value="add_assigne" name="add_assigne"> </li> <?php if (empty($_POST['add_assigne']) === false) { add_assigne($user_1, $_POST['assigne'], $pid); This is working, but I want the dropdown to update itself with the new users after submit is pressed... Quote Link to comment Share on other sites More sharing options...
adam_bray Posted January 1, 2014 Share Posted January 1, 2014 If you move the delete query above the select query then it will work as expected. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.