.htm页
<form name="form1" action="../upedit_houtai.php" 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='{*$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='{*$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="{*$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='{*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='{*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;">{*$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 
include("lianjie.php");$hid = !empty($_GET['hid'])?intval($_GET['hid']):0;
/********************数据更新******************/
if(isset($_POST['job']) && $_POST['job']=="edit"){

    $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'";
    //$MySql_update=addslashes($MySql_update);
    $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("数据不存在");
}
?>
<?php
include_once("smarty_config.php");
$smarty->assign("hotel_id",$row[hotel_id]);
$smarty->assign("start_date",$row[start_date]);
$smarty->assign("end_date",$row[end_date]);
$smarty->assign("source",$row[source]);
$smarty->assign("s_type",$row[s_type]);
$smarty->assign("content",$row[content]);
$smarty->display('templates/upedit.htm'); 
?>

解决方案 »

  1.   


    我用之前把这两页代码写在一起,之后用smarty这样写后,传不了值
    这是smarty
    include_once("libs/Smarty.class.php"); //引用smarty 类文件 $smarty = new Smarty();  //smarty对象
    $smarty->config_dir="libs/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;  //缓存时间
    ?>
      

  2.   

    $hid = !empty($_GET['hid'])?intval($_GET['hid']):0; 
    应该是没有取到这个$hid 所以这个值为0 更新没成功
    把问题描述清楚 那怕如果有报错 贴出报错的语句都可以
      

  3.   

    现有的代码
    $hid = !empty($_GET['hid'])?intval($_GET['hid']):0;看不出 hid 在哪里传值。注意你的表单是POST传值你可以设定action里加个?hid=…
      

  4.   

    <form name="form1" action="?hid=$hid../upedit_houtai.php" method="post" onsubmit="return Check();">
    这样

      

  5.   

    不是,,你要按smarty的传值方式
    ……action="../upedit_houtai.php?hid={*$hid*}"……而在php页面,需要传值hid,跟其他变量一样的方式
      

  6.   

    PHP页里我写了$smarty->assign("hid",$row[hid]);
      

  7.   

    还是不行是不是
    这个的问题<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='{*s_type*}'/> 
              输入数字
            </td>
        </tr>
    value='{*s_type*}'的问题
      

  8.   

    value='{*s_type*}'   value='{*$s_type*}'要有$符号
      

  9.   

    $smarty->display('templates/upedit.htm'); 
    你确定你这样子引用没有出错?
    $smarty->display('upedit.htm'); 
    你已经在配置文件里面说明模板是templates这个文件夹 不用再加了
      

  10.   

    我加与不加这个templates都不行