通过第一页的按钮<a href="up_load.php?hid=' . $row['h_id'] . '">编辑</a>,在第二页获取选定的值,并把值传递到第二页input中
<table border=1 height=100 width=400 align="center">
 <tr> 
    <td>hotel_id: </td> 
    <td> <input name="hotel_id" type="text"  value='$rows[hotel_id]' size=45 /> </td>
    </tr>
    <tr>
    <td>start_date: </td> 
    <td> <input name="start_date" type="text"  value='$rows[start_date]'size=45> </td>
    </tr>
    <tr>
    <td>end_date: </td> 
    <td> <input name="end_date" type="text"  value='$rows[end_date]'size=45> </td>
    </tr>
    <tr> 
    <td>content: </td>
    <td> <input name="animal" type="text"  value='$rows[news_date]'size=45> </td> 
    </tr>
    <tr>
    <td>source: </td>"; 
    <td> <input name="source" type="text"  value='$rows[source]'size=45> </td> 
    </tr> 
    <tr>
    <td>s_type:</td>
    <td> <input name="s_type" type="text" value="$rows[s_type]"> </td>
    </tr>
    <tr>
    <td> </td>
    <td> <input name="submit" type="submit"  value="用户更新"> <input  name="fanhui" type="button"  value="返回" onClick="window.open ('index_baocun.php')"></td>
</tr></table>
该怎么写啊

解决方案 »

  1.   

    类似这样:
    <input name="hotel_id" type="text"  value='<?php $rows[hotel_id]; ?>' size=45 />
      

  2.   

    你也可以把html当做字符串输出
      

  3.   


    //up_load.php
    $hid = !empty($_GET['hid']) ? intval($_GET['hid']) : 0;$sql = "SELECT * FROM "……………………" WHERE hid=" . $hid;//把数据搜索出来没有找到的时候,参数非法
    //否则,对应的input里,显示对应的值
      

  4.   

    楼上的大侠们
    为什么文本框中没有值啊
    <form action="upedit.php" method="get">
    <table border=1 height=100 width=400 align="center">
         <tr> 
        <td>hotel_id: </td> 
        <td> <input name="hotel_id" type="text"  value='<?php $rows[hotel_id]; ?>' size=45 /> </td>
        </tr>
        <tr>
        <td>start_date: </td> 
        <td> <input name="start_date" type="text"  value='<?php $rows[start_date];?>'size=45> </td>
        </tr>
        <tr>
        <td>end_date: </td> 
        <td> <input name="end_date" type="text"  value='<?php $rows[end_date];?>'size=45> </td>
        </tr>
        <tr> 
        <td>content: </td>
        <td> <input name="animal" type="text"  value='<?php $rows[news_date];?>'size=45> </td> 
        </tr>
        <tr>
        <td>source: </td>"; 
        <td> <input name="source" type="text"  value='<?php $rows[source];?>'size=45> </td> 
        </tr> 
        <tr>
        <td>s_type:</td>
        <td> <input name="s_type" type="text" value='<?php $rows[s_type];?>' size=45> </td>
        </tr>
        <tr>
        <td> </td>
        <td> <input name="submit" type="submit"  value="用户更新"> <input  name="fanhui" type="button"  value="返回" onClick="window.open ('index_baocun.php')"></td>
    </tr></table></form>
    这是upedit.php
    <?php
    $db_host="127.0.0.1:3306";
    $db_user="root";
    $db_psw="";
    $db_name="mysql";
    $connection=mysql_connect($db_host,$db_user,$db_psw)or die("连接服务器失败");
    mysql_select_db($db_name,$connection)or die("选择数据库失败");
    //从数据库里去数据 
    $hid = !empty($_GET['hid'])?intval($_GET['hid']):0;
    $hotel_id=$_GET['hotel_id'];
    $start_date=$_GET['start_date']; 
    $end_date=$_GET['end_date']; 
    $content=$_GET['content']; 
    $source=$_GET['source']; 
    $s_type=$_GET['s_type']; 
    $MySql_update=mysql_query("update hotel_activities_2 set hotel_id='$hotel_id',start_date='$start_date',end_date='$end_date',content='$content',source='$source',s_type='$s_type' where h_id='$hid"); 
    $result=mysql_query($MySql_update); 
    echo mysql_errno(); 
    if ($result) { 
    echo '数据更新成功!'; 
    }else { 
    echo '数据更新失败!'; 

    //更新结束
    ?>
      

  5.   

    $sql = "SELECT * FROM hotel_activities_2 where hid='.$hid'"; 
    $result2=mysql_query($sql) or die("查询失败");
    //$hid = !empty($_GET['hid'])?intval($_GET['hid']):0;
    $hotel_id=$_GET['hotel_id'];
    $start_date=$_GET['start_date']; 
    $end_date=$_GET['end_date']; 
    $content=$_GET['content']; 
    $source=$_GET['source']; 
    $s_type=$_GET['s_type']; 
    $MySql_update=mysql_query("update hotel_activities_2 set hotel_id='$hotel_id',start_date='$start_date',end_date='$end_date',content='$content',source='$source',s_type='$s_type' where h_id='$hid"); 
    $result=mysql_query($MySql_update); 
    echo mysql_errno(); 
    if ($result) { 
    echo '数据更新成功!'; 
    }else { 
    echo '数据更新失败!'; 

    ??
      

  6.   

    要类似这样去取值
    while($result=mysql_query($MySql_update)){
        echo $result['colum_name'];
    };
    多看看PHP手册:
    http://www.php.net/manual/en/function.mysql-query.php
      

  7.   

    $sql = "SELECT * FROM hotel_activities_2 where hid='.$hid'"; 
    $result2=mysql_query($sql) or die("查询失败");
      

  8.   

    这是我编辑后台代码:
    <?php
    $db_host="127.0.0.1:3306";
    $db_user="root";
    $db_psw="";
    $db_name="mysql";
    $connection=mysql_connect($db_host,$db_user,$db_psw)or die("连接服务器失败");
    mysql_select_db($db_name,$connection)or die("选择数据库失败");
    //从数据库里去数据 
    $hid = !empty($_GET['hid'])?intval($_GET['hid']):0;
    $sql = "SELECT * FROM hotel_activities_2 where hid='.$hid'"; 
    $result2=mysql_query($sql) or die("查询失败");
    $hotel_id=$_GET['hotel_id'];
    $start_date=$_GET['start_date']; 
    $end_date=$_GET['end_date']; 
    $content=$_GET['content']; 
    $source=$_GET['source']; 
    $s_type=$_GET['s_type']; $MySql_update=mysql_query("update hotel_activities_2 set hotel_id='$hotel_id',start_date='$start_date',end_date='$end_date',content='$content',source='$source',s_type='$s_type' where h_id='$hid"); 
    $result=mysql_query($MySql_update); 
    echo mysql_errno(); 
    if ($result) { 
    echo '数据更新成功!'; 
    }else { 
    echo '数据更新失败!'; 

    //更新结束
    ?>
      

  9.   

    大侠们帮帮忙吧 
    这是我改后的编辑后台
    $db_host="127.0.0.1:3306";
    $db_user="root";
    $db_psw="";
    $db_name="mysql";
    $connection=mysql_connect($db_host,$db_user,$db_psw)or die("连接服务器失败");
    mysql_select_db($db_name,$connection)or die("选择数据库失败");
    //从数据库里去数据 
    $hid = !empty($_GET['hid'])?intval($_GET['hid']):0;
    $sql = "SELECT * FROM hotel_activities_2 where hid='.$hid'"; 
    /*$result2=mysql_query($sql) or die("查询失败");
    $hotel_id=$_GET['hotel_id'];
    $start_date=$_GET['start_date']; 
    $end_date=$_GET['end_date']; 
    $content=$_GET['content']; 
    $source=$_GET['source']; 
    $s_type=$_GET['s_type']; */
    while($result=mysql_query($sql)){
      echo $result['hotel_id'];
      echo $result['start_date'];
    echo $result['end_date'];
    echo $result['content'];
    echo $result['source'];
    echo $result['s_type'];
    };$MySql_update="update hotel_activities_2 set hotel_id='$hotel_id',start_date='$start_date',end_date='$end_date',content='$content',source='$source',s_type='$s_type' where h_id='$hid"; 
    $result=mysql_query($MySql_update); 
    echo mysql_errno(); 
    if ($result) { 
    echo '数据更新成功!'; 
    }else { 
    echo '数据更新失败!'; 

    前台是:<form action="upedit.php" method="get">
    <table border=1 height=100 width=400 align="center">
     <tr> 
        <td>hotel_id:</td> 
        <td> <input name="hotel_id" type="text"  value='<?php $rows[hotel_id]; ?>' size=45 /> </td>
        </tr>
        <tr>
        <td>start_date:</td> 
        <td> <input name="start_date" type="text"  value='<?php $rows[start_date];?>'size=45/> </td>
        </tr>
        <tr>
        <td>end_date: </td> 
        <td> <input name="end_date" type="text"  value='<?php $rows[end_date];?>'size=45/> </td>
        </tr>
        <tr> 
        <td>content: </td>
        <td> <input name="animal" type="text"  value='<?php $rows[news_date];?>'size=45/> </td> 
        </tr>
        <tr>
        <td>source: </td>
        <td> <input name="source" type="text"  value='<?php $rows[source];?>'size=45/> </td> 
        </tr> 
        <tr>
        <td>s_type:</td>
        <td> <input name="s_type" type="text" value='<?php $rows[s_type]; ?>' size=45/> </td>
        </tr>
        <tr>
        <td> </td>
        <td> <input name="submit" type="submit"  value="用户更新"/> <input  name="fanhui" type="button"  value="返回" onClick="window.open ('index_baocun.php')"/></td>
    </tr></table>
    </form>
    我通过按钮<a href="up_load.php?hid=' . $row['h_id'] . '">编辑</a>来传值