我正在公司实习,我正在开发一个应用程序,可以管理该公司的车队,人们可以预订,看到预订等。我有一个页面,人们可以看到预订。在我使用Linux(Antergos)的笔记本电脑上,我使用Lamp来开发我的应用程序。在我的Linux中一切正常,但是当我在Windows中使用Wamp尝试代码时,可以查看预订的页面无法正常工作。 除了事实之外,我刚从3月份开始使用PHP,所以如果代码看起来非常简陋,我很抱歉。
给出的错误是:
注意:未定义的索引:第65行的C:\ wamp64 \ www \ 1 \ ver_reservas.php中的data_de_reserva调用堆栈#TimeMemoryFunctionLocation 10.0014255064 {main}()... \ ver_reservas.php: 0" />
这是我收到错误的地方:
<input name="calendario" type="text" id="calendario" size="10" autocomplete="off" value="<?php echo $_REQUEST["data_de_reserva"]; ?>" />
以下是我的其余代码:
<?php
include 'connect_database.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="pt-pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Gestão de Viaturas</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js">
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ek+Mukta">
<link rel="icon" href="_imagens/favicon2.png">
<style>
body, td {
font-size:12px;
}
</style>
</head>
<body>
<div class="logo">
<img src="_imagens/logo2.jpg" alt="logo">
</div>
<nav class="menu">
<ul class="clearfix">
<li><a href="home.php">Bem vindo <u><?php echo getenv('USERNAME');?></u></a></li>
<li><a href="#">Reservas <span class="arrow">▼</span></a>
<ul class="sub-menu">
<li><a href="reservas.php">Fazer Reservas</a></li>
<li><a href="ver_reservas.php">Ver Reservas</a></li>
</ul>
</li>
<li><a href="#">Adminstração<span class="arrow">▼</span></a>
<ul class="sub-menu">
<li><a href="apagar_reservas.php">Apagar Reservas</a></li>
<li><a href="adicionar.php">Adicionar Carros</a></li>
</ul>
</li>
<li><a href="#">About<span class="arrow">▼</span></a>
<ul class="sub-menu">
<li><a href="#">Saida do carro</a></li>
<li><a href="#">Entrada do carro</a></li>
</ul>
</li>
</ul>
</nav>
</br>
</br>
</br>
</br>
<div id="super">
<div class="datagrid">
</br>
<form id="search_form" name="search_form" method="post" action="ver_reservas.php">
<label for="calendario">Data</label>
<input name="calendario" type="text" id="calendario" size="10" autocomplete="off" value="<?php echo $_REQUEST["data_de_reserva"]; ?>" />
<label>Carro</label>
<select name="carro">
<option value="">--</option>
<?php
$query = "SELECT * FROM reservas GROUP BY carro_usado ORDER BY carro_usado";
$query_result = mysqli_query($con, $query) or die ('request "Could not execute SQL query" '.$query);
while ($row = mysqli_fetch_assoc($query_result)) {
echo "<option value='".$row["carro_usado"]."'".
($row["carro_usado"]==$_REQUEST["carro_usado"] ? " selected" : "").">".$row["carro_usado"]."</option>";
}
?>
</select>
<input type="submit" name="button" id="button" value="Filtrar"/>
</label>
<a href="ver_reservas.php">Limpar</a>
</form>
</br>
<table width="700" border="1" cellspacing="0" cellpadding="4">
<tr>
<td width="110" bgcolor="#CCCCCC"><strong>Nome</strong></td>
<td width="110" bgcolor="#CCCCCC"><strong>Carro</strong></td>
<td width="110" bgcolor="#CCCCCC"><strong>Data</strong></td>
<td width="40" bgcolor="#CCCCCC"><strong>Hora</strong></td>
<td width="40" bgcolor="#CCCCCC"><strong>Hora
Prevista</strong></td>
<td width="290" bgcolor="#CCCCCC">
<strong>Informação</strong></td>
</tr>
<?php
if ($_REQUEST["carro"]<>'') {
$search_carro = " AND
carro_usado='".mysqli_real_escape_string($con, $_REQUEST["carro"])."'";
}
if ($_REQUEST["calendario"]<>'') {
$sql = "SELECT * FROM reservas WHERE data_de_reserva =
'".mysqli_real_escape_string($con, $_REQUEST["calendario"])."'".$search_carro;
} elseif($_REQUEST["calendario"]<>'') {
$sql = "SELECT * FROM reservas WHERE id>0".$search_carro;
} else {
$sql = "SELECT * FROM reservas WHERE DATE(`data_de_reserva`) >= CURDATE()".$search_carro. "ORDER BY data_de_reserva";
}
$sql_result = mysqli_query($con, $sql) or die ('request "Could
not execute SQL query" '.$sql);
if (mysqli_num_rows($sql_result)>0) {
while ($row = mysqli_fetch_assoc($sql_result)) {
?>
<?php $row["data_de_reserva"] = date('d.m.Y', strtotime($row["data_de_reserva"]));
$row["hora"] = date('H:i', strtotime($row["hora"]));
$row["hora_prevista"] = date('H:i', strtotime($row["hora_prevista"]));
?>
<tr>
<td><?php echo $row["nome"]; ?></td>
<td><?php echo $row["carro_usado"]; ?></td>
<td><?php echo $row["data_de_reserva"]; ?></td>
<td><?php echo $row["hora"]; ?></td>
<td><?php echo $row["hora_prevista"]; ?></td>
<td><?php echo $row["informacao"]; ?></td>
</tr>
<?php
}
} else {
?>
<tr><td colspan="6">Nenhum resultado encontrado.</td>
<?php
}
?>
</table>
<script>
$(function() {
var dates = $( "#calendario").datepicker({
defaultDate: "",
changeMonth: true,
numberOfMonths: 1,
dateFormat: 'yy-mm-dd',
onSelect: function( selectedDate ) {
var option = this.id,
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
</script>
</div>
</div>
</body>
</html>