samedi 2 juillet 2016

To display the records retrieved from database into a dialog box

I have a dialog box which takes a number input.I want to send this number to database and retrieve the name corresponding to that number and display it into another dialog box.My code works fine till retrieving the data but I don't know how to display it into another dialog box.I have created a fiddle https://jsfiddle.net/payalsuthar/rdtpo7e3/ and here is dataretrieve.php-

 <?php
    include('db.php');
    $num = $_POST['num'];
    $sql = "SELECT `no`,`name` FROM `table` WHERE `no` = $num ";
     if($result=mysqli_query($conn,$sql)){ 
    //i dont know how to display the values retrieved here into my dialog2(you can check my dialog2)
   }
 ?>

Html code-

<form action="dataretrieve.php" method="POST">
<div id="dialog1" title="div1" style="display:none"> 
Enter the num:<input type="text" name="num" id="num" />
</div>
</form>
<button id="clickMe">Click Me</button>
<div id="dialog2" title="div1" style="display:none"> 
num:<input type="text" name="number" id="number" />

JavaScript code-

$("#clickMe").click(function(){

$('#dialog1').dialog({
buttons:{
"yes":function(){
$(this).dialog('close');
callback(true);
},
"no":function(){
$(this).dialog('close');
}
}
});
function callback(value){
if(value){
$('#dialog2').dialog({
buttons:{
"ok":function(){
$(this).dialog('close');
},
"cancel":function(){
$(this).dialog('close');
}
}
});
}
}
});

Aucun commentaire:

Enregistrer un commentaire