phphtml交互
A. php 和 html 交互问题。想让php返回一个图片网址,以便html来在输出图片。前端怎样获得php返回信息
你想让前段知道solve.php输出地图片的地址?那得用ajax技术,不刷新页面的情况下从数据库取得内容,然后用js处理当前页面内容,就行了。
<img src="solve.php"/>你要是说,src里面可以是个程序地址吗,那是可以的,很多网站的验证码就是这个原理,如1楼所说
B. 一个php 文件与多个html文件如何进行交互
<?php
header("Content-type: text/html; charset=gb2312");
header("Pragma: no-cache");
header("Expires: 0");
@$action = $_REQUEST ['action'];
$sid = MyTool::generateId ();
if (! $action)
$action = "list";
Trace::debug ( $action );
if ($action == "save") {
$reply = $_REQUEST ['reply'];//获取回复值
print_r($reply);
$id = $_REQUEST ['f_id'];
CourseService::updateApplyState($db,$id,TrainApply::STATUS_PASS);
$apply=CourseService::getTrainApply($db,$id);
$student=$apply->owner;
$trainId=$apply->train;
$train=CourseService::getTrainSchele($db,$trainId);
$pass_test=$train->test==""?0:-1;
$pass_judge=$train->judge==""?0:-1;
$pass_readrate=$train->readrate==""?0:-1;
$pass_feedback=$train->feedback==""?0:-1;
$mc = new MyCourse();
$mc->schele_id = $train->id;
$mc->course_id = $train->course_id;
$mc->user_id = $student;
$mc->type = $train->catalog;
$mc->state = MyCourse::STATE_WAITING;
$mc->pass_test = $pass_test;
$mc->pass_judge =$pass_judge ;
$mc->pass_feedback = $pass_feedback;
$mc->pass_readrate = $pass_readrate;
$mc->score = $train->score;
$mc->starttime = $train->starttime;
$mc->endtime = $train->endtime;
$mc->coursename = $train->name;
CourseService::save($db, $mc);
print"<script>alert('通过操作成功!');window.close();location.href='applyreply.php?action=list'</script>";
}
if ($action == "reject") {
$id = $_REQUEST ['f_id'];
$sql = "update t_train_apply set f_status=2 where f_id='".$id."'";
Trace::debug ( $sql );
$db->Execute ( $sql );
print"<script>alert('拒绝操作成功!');window.close();location.href='applyreply.php?action=list'</script>";
}
if ($action == "list") {
$pagination = new MyPagination(0,1);
$UserID = $_SESSION[AuthorizationHelper::SESSION_USER_KEY]['id'];
$as = CourseService::listApply($db,$pagination,null,null,null,$UserID);
//print_r($as);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<?= HTMLTool::includeResource() ?>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">
$(function() {
$('#tabs').tabs({spinner:'加载...',fx:{ opacity: 'toggle' },selected:2});
});
function passIt(id){
var url = '<?php print $_SERVER['PHP_SELF'] ?>';
var pars = 'action=pass&f_id='+id;
alert(url+"?"+pars);
// open(url+"?"+pars);
var myAjax = new Ajax.Request(
url,
{
method: 'get',
parameters: pars,
onComplete:done
});
afterPass(id);
}
function afterPass(id){
// alert(originalRequest.responseXML);
// var result = originalRequest.responseXML.getElementsByTagName("id");
// alert(result.length);
document.getElementById('button_'+id).style.display='none';
document.getElementById('status_'+id).innerHTML='通过';
}
function rejectIt(id){
var url = '<?php print $_SERVER['PHP_SELF'] ?>';
var pars = 'action=reject&f_id='+id;
//alert(url+"?"+pars);
var myAjax = new Ajax.Request(
url,
{
method: 'get',
parameters: pars,
onComplete:done
});
afterReject(id);
}
function afterReject(id){
// alert(originalRequest.responseXML);
// var result = originalRequest.responseXML.getElementsByTagName("id");
// alert(result.length);
document.getElementById('button_'+id).style.display="none";
document.getElementById('status_'+id).innerHTML="驳回";
}
function done(){
alert("操作成功");
}
</script>
</head>
<body >
<!-- 导航栏 -->
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="navigationbar" class="navigationbar">
<tr><td height="28" >您现在的位置: <a href="../welcom.php">首页</a> >> <a href="#">考试管理</a> >>考试申请管理</td></tr>
</table>
<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td valign="top">
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="listtable">
<thead>
<tr>
<td width="150">考试名称</td>
<td>申请原因</td>
<td width="150">申请人</td>
<td width="130">申请时间</td>
<td width="80">状态</td>
<td width="80">管理</td>
</tr>
</thead>
<?php
//foreach($as as $a){
//Trace::debug($a);
//$schele = CourseService::getTrainSchele($db,$a->train);
//$u = UserService::getUser($db,$a->owner);
?>
<tr>
<td><?= $schele->name ?></td>
<td><?= $a->name ?></td>
<td><?= $u->trueName ?></td>
<td><?= MyTool::formatDate($a->createtime)?></td>
<td><span id="status_<?= $a->id ?>"><?= TrainApply::$STATUS_ARRAY[$a->status]?></span></td>
<td> <span id="button_<?= $a->id ?>">
<?php if($a->status==TrainApply::STATUS_WAITING) {?>
<a href="?action=pass&f_id=<?= $a->id ?>">通过</a>
<a href="application_manage.php?action=reject&f_id=<?= $a->id ?>">拒绝</a>
<?php } ?>
</td>
</tr>
<?php //} ?>
</table>
<?php include($_SERVER['DOCUMENT_ROOT']."/train/common/pagination.php")?>
</td>
</tr>
</table>
</body>
</html>
<?php }?>
<?php if($action=="pass") {//回复
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<?= HTMLTool::includeResource() ?>
<script >
$(document).ready(function(){
$("#commonForm").validate();
});
</script>
</head>
<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="border_left_up"></td>
<td class="border_middle_up"><span class="pagetitle">建议回复</span></td>
<td class="border_right_up"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="border_left_middle"> </td>
<td align="center">
<form id="commonForm" method="post">
<input type="hidden" name="action" value="save"/>
<input type="hidden" name="id" value="<?php print $_REQUEST ['id']?>" />
<textarea class="required" rows="10" cols="120" name="reply" maxlength="500">您的建议已采纳,谢谢参与</textarea><br>
<span class="btn_green"><span><button type="submit" id="sure">提 交</button></span></span>
</form>
</td>
<td class="border_right_middle"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="border_left_down"></td>
<td class="border_middle_down"> </td>
<td class="border_right_down"></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<?php } ?>
就是你要的效果,,看仔细点只看标签与判断就行
C. html怎么使用ajax和php交互
用jqurey.min.js
$.post("php",function(data){
});
D. 下面一段关于HTML与PHP代码交互用来显示不同问候语的例子
<html>
<title>在不同的时间显示不同的问候语</title>
<body><?php
date_default_timezone_set("Asia/Shanghai"); //设置默认时区
$h=date("H"); //取得一个表示小时的数字if($h<12){
echo"早上好!";
}else{
echo"您好!";
}
?>
</body>
</html>
E. html与php通过ajax交互的问题,无法处理中文。
这个demo我复制下来运行挺好的,没毛病
F. 如何用php与html实现交互,html应该如何写是正常写,还是要特殊处理
html里面包含php 就是<div><?php echo “php”; ?></div>
php 里面输出html 就 <?php echo “<a>html</a>”; ?>
你说的连接起来,交互是什么意思?
如果要点击一个连接 就跳到 php的话, 就是 <a href="1.php">php</a> 或者用form post
如果要点击一个连接 然后从php得到信息的话,那么就用ajax。那么ajax的东西 去网络一下即可。
G. php与html交互。
你html页面用ajax异步请求php页面,
然后php页面对提交的数据验证,将验证信息封装成一个json数据返回给html就行,
总之,就是你去了解一下ajax就很简单
H. html与php交互的问题
浏览器发请求到服务器 服务器解析请求并提取数据 服务器将数据转换为html 服务器把最后解析完成的html返给浏览器
I. php如何结合html调用数据
在html中调用php内容,可以用<script src="friendlinks.php"></script>然后在friendlinks.php中调取数据库数据。并输出适当的html,或者输出xml、json都可以,只是图简单的话,只要输出html就行了。