|
|
|
สอบถามครับจะให้ sweet alert2 ดึงข้อมูลจาก DB ต้อง ทำอย่างไรครับ |
|
|
|
|
|
|
|
ตัวดึงข้อมูล
<?php
$db = new PDO("mysql:host=localhost;dbname=mydata","root","");
$stmts = $db->prepare("select * from access Where User_Id= $UserID OR File_Id = 0 ");
$stmts->execute();
while($rows = $stmts->fetch()){
$stmt = $db->prepare("select * from newfiles Where Id = ".$rows['File_Id']." OR User= $UserID ");
$stmt->execute();}
while($row = $stmt->fetch()){
?>
SweetAlert
<script>
function Share() {
swal.fire({
title: "Who will you share?",
html: '<form name="Share" method="get" action="Share.php" enctype="multipart/form-data">'+
'<input type="text" name="username" id="username" class="form-control mb-3" style="color: #574ae2;" placeholder="Username" required>'+
'<input type="hidden" name="file" id="file" class="form-control mb-3" style="color: #574ae2;" value="<?php $row['filename'] ?>" required>'+
'<button class="btn btn-cloud btn-block my-3" type="submit" name="Submit" value="Submit" ><i class="fas fa-sign-in-alt"></i> Submit</button>'+
'</form>',
type: "info",
showCancelButton: true,
showConfirmButton: false,
confirmButtonColor: "Red",
closeOnConfirm: false,
closeOnCancel: false,
}).then((result) => {
if (result.value) {
} else {
swal.fire('Cancelled','You Cancelle', 'error');
}
});
}
</script>
Tag : PHP, MySQL, HTML, JavaScript, jQuery
|
|
|
|
|
|
Date :
2019-03-22 13:03:33 |
By :
BlackBird |
View :
1457 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
swal({ title: '', html: '<button id="sw-save" >save</button>',
onOpen:()=>{
$.ajax({ url: 'getdata.php', success: r=>{
// set data to input object
}});
$('#sw-save').click(()=>{
// แทน preConfirm then
});
}
});
|
|
|
|
|
Date :
2019-03-22 14:36:24 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|