【发布时间】:2020-11-19 10:14:36
【问题描述】:
您好,我想列出所选日期之间的所选客户发票。
我已经创建了一个表单
<form action="raporlar.php" method="POST">
<div class="col-md-3">
<label for="">Customer Name</label>
<select name="customerID" id="customerID" required="" class="form-control">
<option value="">Select a customer</option>
<?php
$musteriSor=$db->prepare('SELECT * FROM customer');
$musteriSor->execute();
while ($musteriCek=$musteriSor->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?php echo $musteriCek['ID']; ?>"><?php echo $musteriCek['adi']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-7">
<div class="row">
<div class="col-md-6">
<label for="">First Date</label>
<input type="date" name="firstDate" required="" class="form-control">
</div>
<div class="col-md-6">
<label for="">Second Date</label>
<input type="date" name="secondDate" required="" class="form-control">
</div>
</div>
</div>
<div class="col-md-2">
<input type="submit" name="raporla" value="Raporla" class="btn">
</div>
</form>
这是我的 sql 查询
<?php
$queryim = 'SELECT * FROM invoice WHERE customerID=:customerID and date=:date BETWEEN '.$_POST['firstDate'].' AND '.$_POST['secondDate'].'';
$faturaSor=$db->prepare($queryim);
$faturaSor->execute(array('customerID'=>$_POST['customerID']));
while ($faturaCek=$faturaSor->fetch(PDO::FETCH_ASSOC)) {
...
}
?>
它给出了这个错误 -> 警告:PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: 绑定变量的数量与 /test.local 中的标记数量不匹配/raporlar.php 第 89 行
如何列出选定的 2 个日期之间的选定客户订单或发票。
【问题讨论】: