我是PHP和MySQL的新手。如何在两个不同的日期之间总结我的图书馆系统中的惩罚。这是我的代码:
<html>
<body>
<form action="" method="get">
<input style="width:300px;" type="text" name="d1" class="tcal">
<input style="width:300px;" type="text" name="d2" class="tcal">
<input style="width:100px;" type="submit" name="submit" value="SEARCH">
<?php
if (isset($_GET["d1"])) {
$d1 = $_GET["d1"];
} else {
$d1 = "";
}
;
if (isset($_GET["d2"])) {
$d2 = $_GET["d2"];
} else {
$d2 = "";
}
;
$result = mysql_query("SELECT SUM(penalty) AS value_sum FROM returned where date_return like '%$d1%' and date_return like '%$d2%'") or die(mysql_error());
$row = mysql_fetch_array($result);
$sum = $row['value_sum'];
echo "Total Profit:" . $sum;
?>
</form>
</body>
</html>