简体   繁体   中英

Confirmation Dialog in PHP, according to data found in mysql db

  • I am developing some database with a php/css interface...
  • I want to know how can I pop up a Confirmation Dialog in my PHP code, yes/no type, dependending in the consequences of my code. Basicly, if theres something on database or not, tell the user and ask the user how he want to proceed.

Here's part of the code:

$sql = mysql_query($query);
$recResult = mysql_fetch_array($sql);
$existID = $recResult["uniqueID"];
if($existID=="") { 
    ->POPUP HERE CONFIRMATION DIALOGUE "It doesnt exists, add new?"
} else {
    ->POPUP HERE CONFIRMATION DIALOGUE it already exists, wright over old data?
}

As PHP is running on the server side, there is no direct way to display some dialog to the user.

You need to generate a piece of user interface using HTML / CSS / Javascript that enables your user to execute the desired steps.

A very simple example could be

<?php
$sql = mysql_query($query);
$recResult = mysql_fetch_array($sql);
$existID = $recResult["uniqueID"];
if($existID=="") { ?>
    <a href="your_app.php?create=1">
        It doesn't exist, click to add new
    </a> 
<?php
} else { ?>
    <a href="your_app.php?id<?php echo $existID; ?>=&overwrite=1">
        It exists, click to overwrite
    </a> 
<?php
}

This will render a link in the HTML result, which your user can choose to open.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM