|
|
|
ช่วยด้วยครับ! ผมจะเอาค่าจาก Json encode ที่ได้จากการ get ไฟล์ php มาแรนดอมโชว์รูปยังไงครับ |
|
|
|
|
|
|
|
Config.php
$CONFIG['Random']['GamePoints'] = 20;
$CONFIG['Random']['WebPoints'] = 1;
$CONFIG['Random']['ITEM'] = array(
'7000133'=>20,
'7000132'=>20,
'7000130'=>20,
'800315'=>10,
'800316'=>10,
'800445'=>10,
'800312'=>5,
'670011'=>1
);
่โค๊ด JS ในหน้าสุ่ม
$( "#BtnRandom" ).click(function () {
var Points;
var Type;
var GC = document.getElementById('GC');
var WP = document.getElementById('WP');
if(GC.checked) {
Type = GC.value;
} else if(WP.checked) {
Type = WP.value;
}
if(Type == 'GamePoints') {
Points = document.getElementById('gcran').innerHTML;
} else if(Type == 'WebPoints') {
Points = document.getElementById('wpran').innerHTML;
}
$.ajax({
type: "GET",
url: "storage/php/process.php",
data: { typepoint : Type, cmd : 'checkrandom'},
success: function(res){
var arr = res.split('#');
var randall = re(arr[2]);
var i2=0;
if(re(arr[0]) >= re(arr[1])) {
for(i=1;i<20;i++) {
i2+=i;
setTimeout(function() {
$('#display-Itemimg').attr('src','storage/images/pon/' + randall[Math.floor(Math.random()*randall.length)] + '.png');
}, i2*20);
}
} else {
alert("Points ของท่านไม่เพียงพอ.., กรุณาเติมเงิน");
}
}
});
})
php ที่โดน Get จากหน้าแรก
if(isset($_GET['cmd']) && $_GET['cmd'] == 'checkrandom' ) {
$conn = db_connect();
$typepoint = clean($_GET['typepoint']);
$str = "SELECT ".$typepoint." FROM UsersData WHERE CustomerID = '".$_SESSION['customerid']."'";
$array = sqlsrv_fetch_array(exec_query( $conn, $str), SQLSRV_FETCH_ASSOC);
$itemarr = array();
foreach ($CONFIG['Random']['ITEM'] as $key => $value) {
array_push($itemarr, $key);
}
echo $array[$typepoint]."#".$CONFIG['Random'][$typepoint]."#".json_encode($itemarr);
exit();
}
นี่คือค่าที่ได้มาจาก Get ครับ
999999949#20#[7000133,7000132,7000130,800315,800316,800445,800312,670011]
Tag : PHP
|
ประวัติการแก้ไข 2019-06-05 13:38:34 2019-06-05 13:39:33
|
|
|
|
|
Date :
2019-06-05 13:35:21 |
By :
guoatni |
View :
753 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|