为什么我在行值''$ date_result'中出现这种错误?
$datenow = date("Y-m-d");
$firstscheduletimemorning = "08:00AM-12:00NN";
$firstscheduletimeafternoon = "01:00PM-05:00PM";
if ((date('N', strtotime($datenow)) == 6))
{
$unix_time_for_first_interview = strtotime( $datenow ); // covert date to unix time
$sec_in_2_days = 60 * 60 * 24 * 2; // 60 seconds * 60 minutes * 24 hours * 30 days
$new_unix_time_for_first_interview = $unix_time_for_first_interview + $sec_in_2_days; // add 30 days to unix time
$date_result = date('Y-m-d', $new_unix_time_for_first_interview ); // convert new unix time to date
$result = mysql_query("SELECT *
FROM tbl_interview_schedule
WHERE firstscheduledate = '$date_result'
AND firstscheduletime = '$firstscheduletimemorning'");
$num_rows = mysql_num_rows($result);
if($num_rows == 15)
{
$afternoonresult = mysql_query("SELECT *
FROM tbl_interview_schedule
WHERE firstscheduledate = '$date_result'
AND firstscheduletime = '$firstscheduletimeafternoon'");
$afternoonnum_rows = mysql_num_rows($afternoonresult);
if($afternoonnum_rows < 15)
{
$HTML = '';
$HTML .= '<tr>';
$HTML .= '<td><label>Schedule Interview:</label></td>';
$HTML .= '<td><input type="text" name="scheduledate" id="scheduledate-txt" class="inputform-design" value='$date_result'></td>';
$HTML .= '<td><input type="date" name="scheduledatepicker" id="scheduledatepicker-txt" class="inputform-design"></td>';
$HTML .= '<td><select name="scheduletime" id="scheduletime-txt" class="inputform-design">';
$HTML .= '<option value='$firstscheduletimeafternoon'>$firstscheduletimeafternoon</option>';
$HTML .= '<option value="08:00AM - 12:00NN">08:00AM - 12:00NN</option>';
$HTML .= '<option value="01:00PM - 05:00PM">01:00PM - 05:00PM</option>';
$HTML .= '</select>';
$HTML .= '</td>';
$HTML .= '</tr>';
}
echo $HTML;
}
}
答案 0 :(得分:1)
$HTML .= '<td><input type="text" name="scheduledate" id="scheduledate-txt" class="inputform-design" value='$date_result'></td>'
应该是:
$HTML .= '<td><input type="text" name="scheduledate" id="scheduledate-txt" class="inputform-design" value='.$date_result.'></td>'
和
$HTML .= '<option value='$firstscheduletimeafternoon'>$firstscheduletimeafternoon</option>';
应该是:
$HTML .= '<option value='.$firstscheduletimeafternoon.'>'.$firstscheduletimeafternoon.'</option>';
*请注意mysql扩展名is now deprecated and will be removed sometime in the future。那是因为它古老,充满了不良做法,缺乏一些现代特色。不要用它来编写新代码。请改用PDO或mysqli_*。
答案 1 :(得分:0)
$HTML .= '<option value='$firstscheduletimeafternoon'>$firstscheduletimeafternoon</option>';
应该是
$HTML .= '<option value="'.$firstscheduletimeafternoon.'">'.$firstscheduletimeafternoon.'</option>';
注意连接字符串的.
。
$HTML .= "<option value='$firstscheduletimeafternoon'>$firstscheduletimeafternoon</option>";
也是一种选择。如果使用双引号,则可以解释其中的变量。
答案 2 :(得分:0)
你在线上错过了连接运算符。它应该是
$HTML .= '<td><input type="text" name="scheduledate" id="scheduledate-txt" class="inputform-design" value='.$date_result.'></td>';
你也错过了其他地方。 (请参阅option
行)
答案 3 :(得分:0)
您希望使用连接字符串运算符,如下所示:
value="'.$date_result.'"