0

我从数据库中传递日期并设置 dateforService 的值,然后将 URL 值发送到另一个 php 文件以更新数据库。但是每次我尝试保存在数据库中时,它都会保存为 0000-00-00。

以下是以下代码:

echo "<td><input type= 'text' name = 'jobrequestnumber' value =".$row['jobrequestnumber']."></td>"  ; // results in the same jobrequestnumbers
echo "<td><input type= 'text' name = 'requestingcompany' value =".$row['requestingcompany']."></td>"    ;//this too
echo "<td><input type= 'date' name = 'dateforService' value =".$row['dateforService']."></td>"  ;// this one also 
echo "<td><a href=\"update_request.php?jobrequestnumber={$row['jobrequestnumber']}&requestingcompany={$row['requestingcompany']}&dateforService={$row['dateforService']}\">Update</a></td>";

因此,我尝试在下面的更新代码之前回显该值:然后它以正确的日期格式出现。

if (empty($errors)){
$jobrequestnumber = $_GET['jobrequestnumber'];
$requestingcompany = $_GET['requestingcompany'];
$dateforService = date("Y-m-d", strtotime($_GET['dateforService']));
    $query =    "UPDATE jobrequest SET 
                        requestingcompany = '{$requestingcompany}',
                        dateforService = $dateforService 
                    WHERE jobrequestnumber ={$jobrequestnumber}";

非常感谢您的建议,非常感谢。

4

1 回答 1

0

代替

dateforService = $dateforService 

dateforService = '$dateforService'

以防万一

代替

jobrequestnumber ='$jobrequestnumber' // remove { & }. You are not using an array here. And add quotes around it
于 2013-05-31T13:39:46.993 回答