php combobox & button should hide once updated int

2019-09-09 23:06发布

问题:

here i updated one field value through user input form (combo box type). update process is working perfectly. but, after data stored in db it should show the value what i'm selected in combo box and then that combox box & update button must hide once updated and it should show message "updated successfully" instead of combo box & button. NOT USING JAVASCRIPT ALERT METHOD. THIS IS NOT A ALERT MESSAGE. once updated data in db that combo box should hide and then success message should show in that particular .

this is my main page coding :

while($a_row = mysql_fetch_array($sql))
    { 
            echo "\t<td>" . $a_row['guestname'] . "</td>";
            echo "\t<td>" . $a_row['agentname'] . "</td>\n";
        echo "\t<td><form action=statusdb.php method=post>
        <select name=update><option value=empty></option><option value=Confirm>Confirm</option><option value=Processing>Processing</option><option value=Pending>Pending</option><option value=Cancelled>Cancelled</option></select>
        <input name=id type=hidden value='".$a_row['slno']."';>
        <input type=submit value=Update>
       </form>
        </td>\n";
        echo "</tr>\n";
    }

this is my statusdb coding :

if (isset($_POST['id']))
{ 
$id = mysql_real_escape_string($_POST['id']);
$update= mysql_real_escape_string($_POST['update']);
$sql = mysql_query("UPDATE guest_details SET status = '$update' WHERE slno = '$id'");
if(!$sql)
{
    die("Error" .mysql_error());
}
else
{
    echo "<html><body onload=\"alert('Status Updated Successfully');\"></body></html>";
}
}

回答1:

I'm thinking this would work.

Try adding the following after the line echoing the agentname:

if ( $a_row['status'] != 'empty' ) {
    echo "\t<td>" . $a_row[$status] . "</td>\n";
} else {
    // here's where you'd put the next 6 lines
}

PS: I don't see an opening <tr> tag.