Jump to content

Update SQL-populated dropdown after submit


stirrah

Recommended Posts

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?

 

 

 

 

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.

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...

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.