create databases handle;
堅守“ 做人真誠 · 做事靠譜 · 口碑至上 · 高效敬業(yè) ”的價值觀,專業(yè)網(wǎng)站建設(shè)服務(wù)10余年為成都履帶攪拌車小微創(chuàng)業(yè)公司專業(yè)提供企業(yè)網(wǎng)站設(shè)計營銷網(wǎng)站建設(shè)商城網(wǎng)站建設(shè)手機(jī)網(wǎng)站建設(shè)小程序網(wǎng)站建設(shè)網(wǎng)站改版,從內(nèi)容策劃、視覺設(shè)計、底層架構(gòu)、網(wǎng)頁布局、功能開發(fā)迭代于一體的高端網(wǎng)站建設(shè)服務(wù)。
create table user(
id int unsigned not null auto_increment primary key,
name varchar(8),
sex tinyint(1) default '1',
score int not null,
state tinyint(1)
);
2.向表中添加數(shù)據(jù)(不示例)
3.創(chuàng)建index.html客戶端,a.php服務(wù)端1,b.php服務(wù)端2
Index.html:
!DOCTYPE html
html lang="en"
head
meta charset="UTF-8"
title客戶端/title
/head
body
button onclick="send('a.php?state=0')"開始請求/button
div style="position: fixed;width: 500px;height: 300px;top: 100px;background: gray"
span style="color: white;font-size: 20px;"/span
/div
script type="text/javascript" src="./jquery-1.10.2.min.js"/script
script type="text/javascript"
//創(chuàng)建一個模態(tài)框
function display(value){
$('span').html(value);
}
//ajax
function send(dizhi){
$.ajax({
type: "get",
url: dizhi,
success: function(msg){
var arr=JSON.parse(msg);
console.log(arr);
//alert(arr.value);
var tishi="已經(jīng)處理 "+arr.now +"個,共"+arr.all+"個";
display(tishi);
if(arr.now!=arr.all){
send("a.php?now="+arr.now+"all="+arr.all);
}else{
alert("完成!");
}
}
});
}
/script
/body
/html
a.php:
?php
require('./dbconfig.php');
$link=mysql_connect(HOST,USER,PASS) or die('數(shù)據(jù)庫鏈接失敗');
mysql_select_db(DBNAME);
/*
查詢數(shù)據(jù)
$sql="select * from user";
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);
var_dump($row);
*/
/*
循環(huán)插入
for($i=3;$i=100;$i++){
$sql= "insert into user(name,score,state) values('z".$i."',".$i.",1)";
mysql_query($sql);
}
*/
/*查詢需要處理的數(shù)據(jù)總數(shù)*/
//isset($_GET['state'])?$_GET['state']:0;
if(isset($_GET['state'])){
$sql="select count(*) from user";
$result=mysql_query($sql);
$all=mysql_result($result,0);
$now=0;
header("Location: b.php?all={$all}now=0");
}else{
header("Location: b.php?all={$_GET['all']}now={$_GET['now']}");
}
/*返回當(dāng)前處理的數(shù)據(jù)*/
b.php:
?php
require('./dbconfig.php');
$link=mysql_connect(HOST,USER,PASS) or die('數(shù)據(jù)庫鏈接失敗');
mysql_select_db(DBNAME);
/*返回當(dāng)前處理的數(shù)據(jù)*/
//$id=$_GET['id'];//獲取將要處理的id
$now=$_GET['now'];//已經(jīng)處理的個數(shù)
$all=$_GET['all'];//總共要處理的個數(shù)
$sql="select score from user limit {$now},1";
$result=mysql_query($sql);
$value=mysql_result($result, 0);
$now++;
$arr=array(
'now'=$now,
'all'=$all,
'value'=$value
);
//print_r($arr);
echo json_encode($arr);
dbconfig.php:
?php
define('HOST','127.0.0.1');
define('USER', 'root');
define('PASS','root');
define('DBNAME','handle');
其實就是訪問這個php文件,返回一段數(shù)據(jù),一般用json,然后安卓可以解析就行了了。走h(yuǎn)ttp協(xié)議。
你大概要先搞清楚 頁面(前端) 和 PHP(后端) 的關(guān)系;
第一個頁面 由 A.php完成, 提交后 輸入的內(nèi)容 交給B.php 由B.php 生成第二個頁面。
這個時候 A.php已經(jīng)不起作用了。 A.PHP 提交的內(nèi)容在服務(wù)器端的 全局變量$_POST['name']里面(name 就是A.PHP中TEXTAREA 標(biāo)簽的name 屬性值)。
注意 : 第一個頁面不存在了,要想顯示第一個頁面的內(nèi)容,就在B.php.中把第一個頁面復(fù)制一遍。把重新建立一個textarea 標(biāo)簽 默認(rèn)值是你要顯示的值,
本文題目:php向客戶端返回數(shù)據(jù) php獲取接口返回值
本文鏈接:http://jinyejixie.com/article10/hepego.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、自適應(yīng)網(wǎng)站、微信小程序、響應(yīng)式網(wǎng)站、營銷型網(wǎng)站建設(shè)、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)