php combobox & button should hide once updated into mysql db and show success message instead of combobox & button place.

泪湿孤枕 提交于 2019-12-25 04:48:16

问题


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.



来源:https://stackoverflow.com/questions/19218788/php-combobox-button-should-hide-once-updated-into-mysql-db-and-show-success-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!