① php 我只会用HTML混合的方法制作。这样做可以吗
可以,为什么不可以?不过即时你不使用框架或模板引擎,也可以稍微考虑一下内容和表现的简单分离。
② 怎么把php与html嵌套在一起
PHP 和HTML混写:
1.简单的:
<?php
$a = 5;
$b =3;
$c = $a - $b;
echo $c;
?>
<div>HTML 代码 </div>
-----------------------------------------------------------------------
2.用条件语句来控制HTML的输出:
<?php
$a = 6;
$b = rand(1, 10); //产生随机数;
if($a < $b)
{
?>
<div>HTML代码 ,部分1</div>
<?php
}
else
{
?>
<div>HTML代码 ,部分2</div>
<?php
}
?>
这段代码是用PHP来控制HTML的输出,会随机输出 HTML1,HTML2
③ PHP 和HTML 是怎么结合的。用哪些代码能将他们二个连接起来
1、html是用来做网页的表现层的,也就可以看到的。如字体、链接,图片等。
2、php是用来处理逻辑层的,也就是网页提供什么功能,完成什么动作。如查询数据,计算利息,生成图表等。
3、php代码是嵌入html中的。
④ php和html代码怎么弄到一起
你这是属于混编了 我做的其实就这个 呵呵
举个最简单的例子 就用你这个来做
<?
if($num>0){
while($rs=mysql_fetch_array($result)){
?>
<a href='forum.php?page=1&numb=".<?=$rs['id']?>."'>".<?=$rs['name']?>."</a></br>
<?
}
}else{
echo "对不起,论坛尚在建设中……";
}
?>
####<?=$rs['id']?>这个是因为我电脑里开了短标签 所以 可以这么写 如果你电脑里也开了短标签也可以这么些 但是不建议这么做
⑤ php如何与html实现混编
混编如果是php原生态的话就直接嵌入,用框架的话有点不同的
⑥ PHP里如何套html
一般来说有两种混合写法,一种是HTML套PHP,写作<?php ?>;另一种是PHP套HTML,写作<?php echo ?> ,若php开启短标签写法,也可写作<?=$item['RAND']?>
还有一种不太常用的混合写法如下:
easy way to execute conditional html / javascript / css / other language code with php if else:
<?php if (condition):?>
html code to run if condition is true
<?php else: ?>
html code to run if condition is false
<?php endif ?>
列出项目中的一段代码的两种写法:
[php] view plain
<?php if($resitem['PREVIEW']){echo $resitem['PREVIEW'];} else {echo "static/images/bg72.png";}?>
写法二:
[php] view plain
<?php if($resitem['PREVIEW']): ?> <?=$resitem['PREVIEW']?><?php else: ?>static/images/bg72.png<?php endif ?>
⑦ 开启php与html混编
首先,你要混编的话你的文件后缀必须是php ,这样服务器才会编译里面的php语句,而不是直接输出。
其次,你混编的代码可能是<? echo 'xxx'; ?>形式的,而不是<?php echo 'xxx'; ?>形式的。使用第一种方法需要在php.ini里面设置。
最后,你显示不了的文件应该在浏览器右键查看源代码,可以帮助你分析出错原因,例如html和php代码都被输出了,就是第一个原因。如果有html代码,没有php代码输出,错误原因可能是你的php代码出错。实在找不出问题原因,可以把代码贴出来~
⑧ PHP 与HTML的混编
混编的话,如果你想稍微修改点,你会改动大量的HTML,
如果能使用逻辑模板,使得程序和界面分离,很多时候会使得开发事半功倍。
⑨ 一个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 } ?>
就是你要的效果,,看仔细点只看标签与判断就行