douzhuo2002 2012-09-07 13:59
浏览 7
已采纳

使用php更新我的sql以查看评论页面

So this should be my last question for this entire project. I've made the employee timecard pages. Works great. I'm trying to make them a review/change page per timecard. Basically the initial review page pulls up the timecards they've submitted. They select Review. It carries the ID number to a review page, and I call upon the ID number to display all the info from that timecard into the new timecard html/php form. (Basically its the exact same form they used to submit, however I've echo'd the values as the option already)

When I do update though it's not only carrying over the echo'd value. It's only Updating any changes they make, and in fact deleting everything else. Below is a snippit of just one drop-down list (all over non drop-down's update fine. This is just for drop down lists where the data is contained in the DB.

 <select name="starttime" id="input_6" style="width:150px">
            <option value="" selected><?php echo $stime ?></option>
          <?php

                $result = mysql_query("SELECT time FROM selTime ORDER BY id");

                 while($row = mysql_fetch_array($result)) {

                 echo "<option value=\"" . $row['time'] . "\">" . $row['time'] . "                                              </option>";

                }

             ?>
      </select>

So what happens with this code. Is when they open the review page They would see their start time as they submitted it. If they leave it alone, and not change anything and push submit after changing something else. The starttime actually UPDATES as blank. If they change the starttime to a value it DOES submit the change. Is there something in this code that I can change that will submit the echo'd value, instead of just displaying it?

  • 写回答

2条回答 默认 最新

  • duanliu6083 2012-09-07 14:04
    关注

    I believe the issue is with this line of code:

    <option value="" selected><?php echo $stime ?></option>
    

    Although you set it as "selected" the selected element has the value of "" (empty). Try changing it to:

    <option value="<?php echo $stime; ?>" selected="selected"><?php echo $stime; ?></option>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值