像我这页怎么分开写
<?php
include("lianjie.php");
/**********************定义函数***********************/
function writedblog($data)
{
    $time=date('Y-m-d H:i:s',time());
    return mysql_query("insert into hotel_rizhi(hotel_id,name,content,operating,time) values ('$data[hotel_id]','$data[name]','$data[content]','$data[operating]','$time')");
}
$hid = !empty($_GET['hid'])?intval($_GET['hid']):0;
/********************数据更新******************/
if(isset($_POST['job']) && $_POST['job']=="edit"){
$MySql_update=addslashes($MySql_update);
    $MySql_update="update hotel_activities_2 set hotel_id='{$_POST['hotel_id']}',start_date='{$_POST['start_date']}',end_date='{$_POST['end_date']}',content='{$_POST['content']}',source='{$_POST['source']}',s_type='{$_POST['s_type']}' where h_id='$hid'";
    $result=mysql_query($MySql_update); 
    echo mysql_errno(); 
    if (isset($_COOKIE["user_name"])){
    $_user=$_COOKIE["user_name"];}//接收用户名
    $logdata['name'] = $_user;
    $logdata['hotel_id']=$_POST['hotel_id'];
    $logdata['content']=$_POST['content'];
    $logdata['operating']="更新";
    writedblog($logdata);//调用函数    if ($result) { 
    echo "<script>alert('数据更新成功');window.location='chaxun.php';</script>";exit();
    }else { 
    echo "<script>alert('数据更新失败');window.location='chaxun.php';</script>";
    } 
}else{
    $sql = "SELECT * FROM hotel_activities_2 where h_id='$hid'"; 
    $result=mysql_query($sql) or die("查询失败");
    $row=mysql_fetch_array($result);
    if(!$row)exit("数据不存在");
    ?>
    
<!--**************更新页面*****************-->
<link href="css/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="javascript/rili.js" charset="utf-8"></script>
<script type="text/javascript">
function Check(){
   var reqInputs=document.getElementsByName("text_name");
   for(var i=0,len=reqInputs.length;i<len;i++){
       if(reqInputs[i].value.length==0){
           alert("请输入指定的信息");
           reqInputs[i].focus();
           return false;
       }
   }
   return true;
}
</script>
<center>
<body>
<form name="form1" action="?hid=<?php echo $hid;?>" method="post" onsubmit="return Check();">
<fieldset style="width:400px;">
<legend>更新</legend>
<table align="right">
     <tr>
        <td width="100" height="30" class="zi">
        <img src="img/38.gif" width="10" height="10"/>酒&nbsp;&nbsp;&nbsp;&nbsp;店id:
        </td>
        <td width="300" align="left" class="zhushi">
        <input name="hotel_id" type="text" id="text_name" value='<?php echo $row[hotel_id]; ?>' width="300" align="left"/>
    *输入数字
    </td>
    </tr>
    <tr>
        <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始时间:</td> 
        <td align="left" class="zhushi">
        <input name="start_date" type="text" id="text_name"  value='<?php echo date('Y-m-d', strtotime($row['start_date']))?>' readOnly onClick="setDay(this);"/>
    *例:年-月-日</td>
    </tr>
    <tr>
        <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>结束时间:</td> 
        <td align="left" class="zhushi">
        <input name="end_date" type="text" id="text_name"  value='<?php echo date('Y-m-d', strtotime($row['end_date']))?>' readOnly onClick="setDay(this);"/>
    *例:年-月-日</td>
    </tr>
    <tr>
         <td height="30" class="zi">           
              <img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:
         </td>
         <td align="left" class="zhushi"><input name="source" type="text" id="text_name"  value='<?php echo $row[source];?>'/> 
            *输入中文
         </td> 
    </tr> 
    <tr>
        <td height="30" class="zi">         
              <img src="img/38.gif" width="10" height="10"/>s_type:
        </td>
        <td align="left" class="zhushi"> <input name="s_type"  type="text" value='<?php echo $row[s_type]; ?>'/> 
          输入数字
        </td>
    </tr>
    <tr> 
        <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容介绍:</td>
        <td width="388">&nbsp;</td>
    </tr>
<tr>
       <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
         <textarea name="content" id="text_name" style="width:300px;height:50px;"><?php echo $row[content];?></textarea>
           *输入中文</td> 
    </tr>
    <tr>
        <td></td>
        <td height="50" colspan="2">
          <input name="job" type="hidden" value='edit'/>
          <input name="submit" type="submit"  value="用户更新" />
          <input  name="fanhui" type="button"  value="返回" onClick="window.location='chaxun.php'"/></td>
   </tr>
</table>
</fieldset>
</form>
<?php
}
?>
</body>
</html>

解决方案 »

  1.   

    $smarty->assign('hotel_id',$row[hotel_id]);<input name="hotel_id" type="text" id="text_name" value='{$hotel_id}' width="300" align="left"/>
            *输入数字
    大概就是这样不是很懂的话 看下php100视频教程 他里面有几节是讲smarty
    http://www.php100.com/html/shipinjiaocheng/
      

  2.   

    看下这个贴子:
    http://topic.csdn.net/u/20100713/21/7f5b5616-9601-4006-a06c-74a2160ce64f.html
      

  3.   

    $smarty->assign("模板中的变量",解析的变量字符!);
    $smarty->display("显示模板")
      

  4.   

    我也知道这么写
    我现在把SMARTY下到了htdocs文件夹下
    htdocs文件下还有ttt文件夹
    我想把ttt文件夹里的PHP分成htm与php,该怎么做
      

  5.   


    <?php
    //smarty配置文件 假设该文件命为smarty_config.php
    include_once("./smarty/Smarty.class.php"); //引用smarty 类文件 $smarty = new Smarty(); //smarty对象
    $smarty->config_dir="Smarty/Config_File.class.php"; 
    $smarty->template_dir =  "templates"; //模板文件夹
    $smarty->compile_dir =  "templates_c"; //编译文件夹
    $smarty->left_delimiter="{*"; //左变量符 默认是{ 但与javascript相冲突 可以自己设定
    $smarty->right_delimiter="*}"; //右 同上
    $smarty->caching=false; //是否开启缓存
    $smarty->cache_dir = "cache"; //缓存目录
    $smarty->cache_lifetime= 60; //缓存时间?>
    你要新建的文件夹有 templates,templates_c,cache再新建一个index.php文件 引用smarty_config.php
    index.php<?php
    include_once("smarty_config.php");
    $smarty->assign("title",'这是标题');
    $smarty->display("index.html");
    ?>
    在templates下新建index.html代码 {$title}http://wenku.baidu.com/view/0d7e6a649b6648d7c1c746ab.html
    这是大师兄smarty教程 入门很不错 建议看看
      

  6.   

    PHP里定义smarty模板路径就可以了啊~~~
      

  7.   

    是要把所有页的html文件放在templates文件夹里