简体   繁体   English

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

[英]Using php to UPDATE my sql for a review page

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. 它将ID号带到评论页面,我调用ID号码将该时间卡中的所有信息显示到新的时间卡html / php表格中。 (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. 下面是一个只有一个下拉列表的snippit(所有非下拉列表的更新都很好。这仅适用于数据包含在数据库中的下拉列表。

 <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? 我可以更改此代码中的哪些内容将提交echo值,而不是仅显示它?

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>

If they dont change this select list item, and submit the page directly, the selected item is the first one with the value="", so this will update in the database with blank ( null). 如果他们不更改此选择列表项,并直接提交页面,则所选项是第一个值为“”的项目,因此这将在数据库中以空白(null)更新。

You need to give your fist item a value of date time now. 您现在需要为您的第一项提供日期时间值。 This code here: 这段代码在这里:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM