我在数据库中填充下拉列表(该部分有效),当我从下拉列表中选择一个项目时,我希望它使用新选择的项目信息并通过我的函数运行它来计算项目生命周期(每个项目的生命周期以年为单位输入数据库)。当我将item_num硬编码到查询中时,它工作正常,但是当我尝试使用下拉列表进行选择时,它什么也没有返回。显然,我错过了一些基本的东西。任何帮助将不胜感激。
<?php
session_start();
include_once 'databaseConnect.php';
if (isset($_POST['itemDropDown'])) {
$submittedValue = $_POST['itemDropDown'];
}
$query = $db->query("select life_cycle, entered_into_service from assets,
all_items where assets.type = all_items.type and assets.make =
all_items.make and assets.model = all_items.model and all_items.item_num
='.$submittedValue'");
$userRow=$query->fetchAll();
function dateDifference($date_1, $date_2, $differenceFormat = '%a')
{
$dateTime1 = date_create($date_1);
$dateTime2 = date_create($date_2);
$interval = date_diff($dateTime1, $dateTime2);
return $interval->format($differenceFormat);
}
function daysRemaining($entered, $life)
{
$date_1 = $entered;
$date_2 = date('m/d/Y');
echo (365 * $life) - dateDifference($date_1, $date_2) ." days";
}
function get_items() {
global $db;
$query = 'SELECT item_num, type, make, model FROM all_items
ORDER BY item_num';
$statement = $db->prepare($query);
$statement->execute();
return $statement;
}
$itemsInfo = get_items();
?>
<html>
<head>
<title>Date Difference</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="mainStyle.css">
<script src="modernizr.custom.05819.js"></script>
</head>
<body>
<table>
<tr>
<th>Days remaining in service:</th>
</tr>
<?php foreach($userRow as $value) : ?>
<tr>
<td><?php
daysRemaining($value['entered_into_service'], $value['life_cycle']); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<form action="" name="items" method="post" >
<label>Available Items:</label>
<select id="itemDropDown" name="itemDropDown">
<option selected="selected">Choose an Item</option>
<?php foreach ($itemsInfo as $itemInfo) : ?>
<option value="<?php echo $itemInfo['item_num']; ?>">
<?php echo $itemInfo['item_num']; ?>
<?php echo $itemInfo['type']; ?>
<?php echo $itemInfo['make']; ?>
<?php echo $itemInfo['model']; ?>
</option>
<?php endforeach; ?>
</select>
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
</body>
</html>
答案 0 :(得分:0)
Permission denied: user=root, access=WRITE,
inode="/root/test/_temporary/0":hdfs:hadoop:drwxr-xr-x
在 $ submittedValue
之前删除点