有人请帮忙!这可能是我犯的一个非常简单的错误,但我是 PHP 和 MySQL 的新手。我正在尝试根据用户的日期选择从数据库中检索信息。我正在使用我在 youtube 上找到的一些示例将输入发布到带有 jquery 的 php 页面,并在 html 页面上显示从 php 检索到的值。但是,它似乎只返回下面的 else if 语句。非常感谢您的帮助!
下面的HTML:
<div id="customDateRange">
<h2>Welcome <?php echo $companyName ?></h2>
<h3 style="color:#ff0000">This is currently under development</h3>
<h4>Please specify the dates you would like to view below:</h4>
<label for="dateStart">Start Date</label>
<input class="datePick" id="dateStart" name="dateStart" type="text"/>
<label for="dateEnd">End Date</label>
<input class="datePick" ud="dateEnd" type="text"/>
<input id="getDateRange" type="submit" value="Display Report" />
<div id="fromDatabase"></div>
</div>
下面的Javascript:
$('.datePick').datepicker({ minDate: new Date(2013, 3 - 1, 1), dateFormat: 'yy-mm-dd' });
$('input#getDateRange').on('click', function(){
var startDate = $('input#dateStart').val();
if ($.trim(startDate) != '') {
$.post('../../includes/dateRangeDB.php', function(data, status){
$('div#fromDatabase').text(data);
});
}
});
PHP 下面:
<?php
if (isset($_POST['dateStart']) === true && empty($_post['dateStart']) === false) {
$query = mysql_query("
SELECT TotalCost FROM adwords_reporting WHERE CampaignID = 'CAMP020' AND Date IN ('" . mysql_real_escape_string(trim($_POST['dateStart'])) . "')
");
echo "Total Cost: " . (mysql_num_rows($query) !== 0) ? mysql_result($query, 0, 'TotalCost') : 'Date Not Found';
}
else if (isset($_POST['dateStart']) === false) {
echo "WTF MAN!";
}
else {
echo "It seems there is an issue";
}
?>
感谢您的帮助!