一旦sql查询成功,就隐藏div

I am trying to make the div, "yourpick," hide once the POST query is successful. I know I'm checking for the POST in the middle of my form, but can we work around this. Thanks.

echo '<div class="yourpick" style="display:block;">
            YOUR PICK:<br><form method="post" action="draft.php">';
    echo '<input type="radio" name="pick" value="user1">User1<br>';

if(isset($_POST["pick"])){
$pick = $_POST["pick"];
$picksql = "UPDATE picks SET playerpick='" . $pick . "' WHERE id=$id AND picknum=$picknum";

if ($mysqli->query($picksql) === TRUE) {
echo "Pick Successful!";
echo "<script>document.getElementById('yourpick').style.display = 'none';</script>";
} else {
echo "Error Ocurred. Please contact commisioner.";
}
}


echo "<input type='submit' name='submit' /></form></div>";

You do not need Javascript for this:

if (isset($_POST["pick"])) {
  $pick    = $_POST["pick"];
  $picksql = "UPDATE picks 
              SET playerpick = '$pick' 
              WHERE id = $id AND picknum = $picknum";
  if ($mysqli->query($picksql) === TRUE) { 
    echo "Pick Successful!";
  } else {
    echo "Error Ocurred. Please contact commisioner.";
  }
}
else {
  echo '<div class="yourpick" style="display:block;">'.
       'YOUR PICK:<br><form method="post" action="draft.php">'.
       '<input type="radio" name="pick" value="user1">User1<br>'.
       '<input type="submit" name="submit"></form></div>';
}

Sorry, but I'm not pointing out the obvious security risks of this code.

It is best imo to use php alternative syntax in the HTML, so if isset($_POST["pick"]), then hide the div:

<?php if(isset($_POST["pick"])): ?>
    <div class="yourpick" style="display:block;">
    YOUR PICK:<br><form method="post" action="draft.php">
    <input type="radio" name="pick" value="user1">User1<br>
    <input type="submit" name="submit"></form></div>
<?php endif; ?>

Makes your code all nice and tidy. :)