0

i am developing database driven web application. I want to show a pop up when MySql query runs successfully. for example

when my database is successfully updated

$result = mysql_query("DELETE FROM students WHERE Roll_No = '$rollno'") or die("SELECT Error: ".mysql_error());
$student_info = mysql_fetch_row($result);


if($result) 
{
    echo "<script> alert('Deleted successfully!')<script>";
        exit;

}
else
{    
echo "<script> alert('Temporary problem, try again!');</script>";
}
?>

it is working fine for me and shows simple JavaScript alert in browser. i want a fancy pop up in the middle of the browser fading the background and auto close after showing the alert say after 10 second. I know it can be done by JavaScript but i don't have enough knowledge of JavaScript, Kindly guide me in the direction so that i can do it or if someone explains me with any example will be great help for me.

user3879357
  • 11
  • 1
  • 4
  • 1
    Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Dec 07 '15 at 16:41
  • 1
    [Your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) – Jay Blanchard Dec 07 '15 at 16:42
  • You will want to look up modal windows in javascript. – Jay Blanchard Dec 07 '15 at 16:42
  • instead of alerting, insert some html and javascript. inside javascript use `setTimeout` to to hide/fadeout the fancy html box after set time of seconds. – Abdul Rehman Dec 07 '15 at 16:43
  • 1
    As jay said. use modals windows of jquery => https://jqueryui.com/dialog/ – Abdul Rehman Dec 07 '15 at 16:44

1 Answers1

1

You can use jQuery for this purpose and design it to your liking.

$(function() {
    $( "#dialog-message" ).dialog({
      modal: true,
      autoOpen: false,
      buttons: {
        Ok: function() {
          $( this ).dialog( "close" );
        });   

Check this page out