|
|
|
ทำยังไงให้ข้อมูลไปแสดงใน pop up ครับ ต้องเขียนอะไรเพิ่มหรือแก้ตรงไหนครับ |
|
|
|
|
|
|
|
code หน้า index ครับ
Code (PHP)
<?php
/*
* include file start***********************************************************
*/
/*
* include file start***********************************************************
*/
/*
* title ***********************************************************************
*/
$pageUrl = 'search';
$pageName = 'index';
$headtitle = 'จัดการสมาชิก';
$title = 'สมาชิก';
$subtitle = '';
$icon = 'fa fa-user';
/*
* title ***********************************************************************
*/
/*
* php code///////////**********************************************************
*/
$db_room = new database();
$option_room = array(
"table" => _prefix."room",
"condition" => "activate='อนุญาต'",
"order" => "codename asc"
);
$query_room = $db_room->select($option_room);
/*
* php code///////////**********************************************************
*/
/*
* header***********************************************************************
*/
require 'template/front/home_header.php';
/*
* header***********************************************************************
*/
?>
<div id="action-success"></div>
<!-- Header -->
<?/* <header class="masthead bg-primary text-white text-center">
<div class="container">
<?/*<img class="img-fluid mb-5 d-block mx-auto" src="<?php echo $baseUrl;?>/application/front/home/freelancer/img/profile.png" alt="">*/?>
<?/* <div class="img-fluid mb-5 d-block mx-auto"><i class="fa fa-book fa-5x"></i></div>
<h1 class="text-uppercase mb-0">KLANGPLAZA APP</h1>
<hr class="star-light mt-5">
<h2 class="font-weight-light mb-5 mt-5">ลูกค้า สามารถตรวจสอบยอดซื้อ และ คะแนนได้</h2>
</div>
<div class="text-center mt-5">
<a class="btn btn-xl btn-outline-light js-scroll-trigger" href="#register">
<i class="fa fa-chevron-down"></i>
</a>
</div>
</header>*/?>
<header class="masthead text-center">
<div class="container">
<div class="row">
<div class="col-md-12">
<form class="form-inline" name="searchform" id="searchform">
<div class="form-group">
<label for="textsearch" >ชื่อสินค้า</label>
<input type="text" name="itemname" id="itemname" class="form-control" placeholder="ข้อความ คำค้นหา!" autocomplete="off">
</div>
<button type="button" class="btn btn-primary" id="btnSearch">
<span class="glyphicon glyphicon-search"></span>
ค้นหา
</button>
</form>
</div>
</div>
<div class="loading"></div>
<div class="row" id="list-data" style="margin-top: 10px;">
</div>
</div>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btnSearch").click(function () {
$.ajax({
url: "<?php echo $baseUrl;?>/front/<?php echo $pageUrl;?>/select_customer",
type: "post",
data: {itemname: $("#itemname").val()},
beforeSend: function () {
$(".loading").show();
},
complete: function () {
$(".loading").hide();
},
success: function (data) {
$("#list-data").html(data);
swal({
title:"\ข้อมูลสมาชิก",
text:"xxxxx",
showCancelButton:false,
confirmButtonText:"ปิด"
})
}
});
});
$("#searchform").on("keyup keypress",function(e){
var code = e.keycode || e.which;
if(code==13){
$("#btnSearch").click();
return false;
}
});
});
</script>
</header>
<?
/*
* footer***********************************************************************
*/
require 'template/front/home_footer.php';
/*
* footer***********************************************************************
*/
?>
|
|
|
|
|
Date :
2018-11-26 13:23:23 |
By :
toeyy8140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
code หน้า select_customer
Code (PHP)
<?php
//echo $_POST['itemname'];
//echo $baseUrl.'<br>';
//echo $basePath;
$db_customer = new database();
$select_customer_id = isset($_POST['itemname']) ? $_POST['itemname'] : "";
$sql_customer = "Select * from "._prefix."customer where CustomerID='{$select_customer_id}' ";
$query_customer = $db_customer->query($sql_customer);
$rows_customer = $db_customer->rows($query_customer);
//if ($rows_customer > 0) {
//while ($rs_customer = mysql_fetch_assoc($query_customeruery)) {
while ($rs_customer = $db_customer->get($query_customer)) {
//$spc = ($rs['group_id']==$rs_group['id']) ? "selected" : "";
echo $rs_customer['CustomerID'].'<br>' ;
echo $rs_customer['MobileNo'].'<br>' ;
echo $rs_customer['FullName'].'<br>' ;
} //}
/*
<?php $i=1; while ($result = mysql_fetch_assoc($query)) { ?>
<tr>
<td><?php echo $i;?></td>
<td><?php echo $result['codename'];?></td>
<td><?php echo $result['itemname'];?></td>
<td><?php echo number_format($result['price']);?></td>
<td><?php echo $result['unit'];?></td>
</tr>
<?php $i++; } ?>*/
//echo 'xxxxx////32944044';
?>
|
|
|
|
|
Date :
2018-11-26 13:24:05 |
By :
toeyy8140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
$.ajax({ url: '.........',
type: 'post',
dataType:'json', // กำหนด type รับ เป็น json
data: {.....},
success: rs=>{
swal({
title:"\ข้อมูลสมาชิก",
html:'<h3>'+rs.CustomerID+'</h3><label>'+rs.MobileNo+'</label>',
showCancelButton:false,
confirmButtonText:"ปิด"
});
}
});
Code (PHP)
//select_customer.php
// ...
// ...
// ...
echo json_encode( $rs_customer);
|
ประวัติการแก้ไข 2018-11-26 13:28:00 2018-11-26 13:35:38 2018-11-26 13:39:59
|
|
|
|
Date :
2018-11-26 13:27:32 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เพิ่มเติมครับ ลองดูครับ
Code (JavaScript)
<script type="text/javascript">
$(document).ready(function(){
$(".launch-modal").click(function(){
$("#myModal").modal({
remote: "../page/page.php"
});
});
});
</script>
|
|
|
|
|
Date :
2018-11-26 13:41:39 |
By :
nobetaking |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 3 เขียนโดย : Chaidhanan เมื่อวันที่ 2018-11-26 13:27:32
รายละเอียดของการตอบ ::
รบกวนดูให้หน่อยครับ ว่าใส่ถูกรึป่าว ผมลองรันแล้วไม่มีอะไรขึ้นมาเลย
Code (PHP)
<?php
/*
* include file start***********************************************************
*/
/*
* include file start***********************************************************
*/
/*
* title ***********************************************************************
*/
$pageUrl = 'search';
$pageName = 'index';
$headtitle = 'จัดการสมาชิก';
$title = 'สมาชิก';
$subtitle = '';
$icon = 'fa fa-user';
/*
* title ***********************************************************************
*/
/*
* php code///////////**********************************************************
*/
$db_room = new database();
$option_room = array(
"table" => _prefix."room",
"condition" => "activate='อนุญาต'",
"order" => "codename asc"
);
$query_room = $db_room->select($option_room);
/*
* php code///////////**********************************************************
*/
/*
* header***********************************************************************
*/
require 'template/front/home_header.php';
/*
* header***********************************************************************
*/
?>
<div id="action-success"></div>
<!-- Header -->
<?/* <header class="masthead bg-primary text-white text-center">
<div class="container">
<?/*<img class="img-fluid mb-5 d-block mx-auto" src="<?php echo $baseUrl;?>/application/front/home/freelancer/img/profile.png" alt="">*/?>
<?/* <div class="img-fluid mb-5 d-block mx-auto"><i class="fa fa-book fa-5x"></i></div>
<h1 class="text-uppercase mb-0">KLANGPLAZA APP</h1>
<hr class="star-light mt-5">
<h2 class="font-weight-light mb-5 mt-5">ลูกค้า สามารถตรวจสอบยอดซื้อ และ คะแนนได้</h2>
</div>
<div class="text-center mt-5">
<a class="btn btn-xl btn-outline-light js-scroll-trigger" href="#register">
<i class="fa fa-chevron-down"></i>
</a>
</div>
</header>*/?>
<header class="masthead text-center">
<div class="container">
<div class="row">
<div class="col-md-12">
<form class="form-inline" name="searchform" id="searchform">
<div class="form-group">
<label for="textsearch" >ชื่อสินค้า</label>
<input type="text" name="itemname" id="itemname" class="form-control" placeholder="ข้อความ คำค้นหา!" autocomplete="off">
</div>
<button type="button" class="btn btn-primary" id="btnSearch">
<span class="glyphicon glyphicon-search"></span>
ค้นหา
</button>
</form>
</div>
</div>
<div class="loading"></div>
<div class="row" id="list-data" style="margin-top: 10px;">
</div>
</div>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btnSearch").click(function () {
$.ajax({
url: "<?php echo $baseUrl;?>/front/<?php echo $pageUrl;?>/select_customer",
type: "post",
dataType:'json',
data: {itemname: $("#itemname").val()},
beforeSend: function () {
$(".loading").show();
},
complete: function () {
$(".loading").hide();
},
success: function (data) {
$("#list-data").html(data);
swal({
title:"\ข้อมูลสมาชิก",
html:'<h3>'+rs.CustomerID+'</h3><label>'+rs.MobileNo+'</label>',
showCancelButton:false,
confirmButtonText:"ปิด"
})
}
});
});
$("#searchform").on("keyup keypress",function(e){
var code = e.keycode || e.which;
if(code==13){
$("#btnSearch").click();
return false;
}
});
});
</script>
</header>
<?
/*
* footer***********************************************************************
*/
require 'template/front/home_footer.php';
/*
* footer***********************************************************************
*/
?>
Code (PHP)
<?php
//echo $_POST['itemname'];
//echo $baseUrl.'<br>';
//echo $basePath;
$db_customer = new database();
$select_customer_id = isset($_POST['itemname']) ? $_POST['itemname'] : "";
$sql_customer = "Select * from "._prefix."customer where CustomerID='{$select_customer_id}' ";
$query_customer = $db_customer->query($sql_customer);
$rows_customer = $db_customer->rows($query_customer);
//if ($rows_customer > 0) {
//while ($rs_customer = mysql_fetch_assoc($query_customeruery)) {
while ($rs_customer = $db_customer->get($query_customer)) {
//$spc = ($rs['group_id']==$rs_group['id']) ? "selected" : "";
echo json_encode( $rs_customer);
} //}
/*
<?php $i=1; while ($result = mysql_fetch_assoc($query)) { ?>
<tr>
<td><?php echo $i;?></td>
<td><?php echo $result['codename'];?></td>
<td><?php echo $result['itemname'];?></td>
<td><?php echo number_format($result['price']);?></td>
<td><?php echo $result['unit'];?></td>
</tr>
<?php $i++; } ?>*/
//echo 'xxxxx////32944044';
?>
|
|
|
|
|
Date :
2018-11-26 13:51:01 |
By :
toeyy8140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
success: function (data) { เท่ากับ success: data=>{
$("#list-data").html(data);
ไม่เหมือนตัวอย่าง apply เอาหน่อยครับ เป็นแค่ตัวอย่าง
ตัวอย่างคือ rs แต่คุณเปิดด้วย data ข้างในก็ต้องแก้เป็น data นะครับ
|
|
|
|
|
Date :
2018-11-26 13:58:05 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตัวอย่าง การใช้ swal สร้าง object สำหรับ login
Code (PHP)
<?php
$sv=explode('.', filter_input(INPUT_SERVER, 'SERVER_NAME'));
$company_list=''; $rs=$this->db->get('companylist')->result();
foreach($rs as $ro){
$company_list.='<option value="'.strtolower($ro->id).'" '.($sv[0]==strtolower($ro->db_name) ? 'selected' : '').' >'.$ro->name.'</option>';
}
?><!doctype html>
<html>
<head>
<title><?=$sv[0]?>: Login</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description" content="Login">
<meta name="author" content="Chaidhanan Pisalsenadhanachote">
<link rel="icon" type="image/x-icon" href="/asset/images/LogIcon.ico" />
<link rel="stylesheet" type="text/css" href="/asset/css/bootstrap.min.css" media="screen">
<link rel="stylesheet" type="text/css" href="/asset/css/font-awesome.min.css">
<script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/asset/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/asset/sweetalert/sweetalert.js"></script>
<script type="text/javascript" src="/asset/js/program/login.js" ></script>
<script type="text/javascript">
var company='<?=$sv[0]?>';
var company_list = `<?=$company_list?>`;
</script>
<style>
td{ padding: 4px;}
.hk_input{ border: 1px solid #898989; text-align: center; width: 80%; font-size: 10pt; height: 27px; border-radius: 5px;}
.hk_input:hover{ border: 2px solid #7676ff; }
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ color: #656565; opacity: 1; /* Firefox */ }
:-ms-input-placeholder { /* Internet Explorer 10-11 */ color: #656565; }
::-ms-input-placeholder { /* Microsoft Edge */ color: #656565;}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-offset-3 col-xs-6"><?=$sv[0]?></div>
</div>
</div>
</body>
</html>
Code (JavaScript)
if(false){
var company_list = '';
}
var ExCeption=(jqXHR, exception)=>{
var msg = '';
if (jqXHR.status === 0) { msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status === 404) { msg = 'Requested page not found. [404]';
} else if (jqXHR.status === 500) { msg = 'Internal Server Error [500].';
} else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.';
} else if (exception === 'timeout') { msg = 'Time out error.';
} else if (exception === 'abort') { msg = 'Ajax request aborted.';
} else { msg = 'Uncaught Error.\n' + jqXHR.responseText; }
swal.showValidationError(msg+'<br>กรุณาทดลองใหม่');
};
var ar={ Login: '', Password:'' };
$(document).ready(()=>{ Login(); });
function Login(){
var html=`<table style="font-size: 10pt; width: 100%">
<tr><td align=right width="30%" >Company</td>
<td><select id="company" class="hk_input" >`+company_list+`</select></td></tr>
<tr><td align=right >User Name</td>
<td><input type="text" id="user" class="hk_input" placeholder="Username [4-10]" value="`+ar.Login+`" ></td></tr>
<tr><td align=right >Password</td>
<td><input type="password" class="hk_input" id="pass" placeholder="Password [4-10]" value="`+ar.Password+`" ></td></tr>
</table>
<b class="btn btn-info" id="login">Login</b><br><br>
<a href="#" id="forgot">Forgot Password</a>`;
swal({
title: 'Login to Your Account', html: html, showCancelButton: false, showConfirmButton: false, backdrop: false,
onOpen: ()=>{
$('.swal2-input').focusin(()=>{swal.resetValidationError();});
$('#user').keyup(e=>{if(e.keyCode===13){$('#pass').focus();}});
$('#pass').keyup(e=>{if(e.keyCode===13 || e.keyCode === 9){ $('#login').click();}});
$('#forgot').click(()=>{
ar.Login=$('#user').val();
if(ar.Login.length<1){
swal('Lost Password Error', 'Please fill in Usename', 'error').then(()=>{ setTimeout( ()=>{ Login();}, 100);});
return;
}
$.ajax({url: '/Home/Lospw', type: 'POST', dataType:'json', data: ar, error: ExCeption, success: rs=>{
if( rs.msg==='complete'){
swal('Your are request Password','I send your password to your Email.<br>Please open your Email', 'success').then(()=>{setTimeout(()=>{ Login();}, 100);});
}else if(rs.msg==='error'){ swal('Request Password Error',rs.error,'error').then(()=>{setTimeout(()=>{ Login();}, 100);});}
}});
});
$('#login').click( ()=>{
ar={ UserID: $('#user').val().toUpperCase(), Password:$('#pass').val() };
if( !(/[A-Z0-9\-_]{2,10}/).test(ar.UserID)){
swal.showValidationError( 'Wrong Name.<br>And must be only in English and numbers.<br>2-10 Digits');
}else if( !(/[a-zA-Z0-9\-_]{2,10}/).test(ar.Password)){
swal.showValidationError( 'Wrong Password<br>And must be only in English and numbers.<br>2-10 Digits');
}else{
$.ajax({ url: '/Home/Login/'+$('#company').val(), type: 'POST', dataType:'json', data: ar, error: ExCeption, success: rs=>{
if( rs.msg==='complete'){ location.href="/Home";}
else{ swal('Request Password Error',rs.error,'error').then(()=>{setTimeout(()=>{ Login();}, 100);});}
}});
}
});
},
preConfirm: ()=>{
return false;
}
}).then(()=>{ Login();});
}
|
|
|
|
|
Date :
2018-11-26 14:17:08 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tag php เขียนให้เต็มทุกครั้งให้เคยชิน จะได้ไม่มีปัญหาเวลาย้าย โฮส หรือ อัพขึ้นโฮส
Code (PHP)
<?php
//....
?>
...
....
<?php
//....
?>
|
|
|
|
|
Date :
2018-11-26 14:27:14 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|