我使用的代码没有给我任何MySQL错误(这很好)
除了它不会显示我正在寻找的结果(在网址栏中它看起来像这个search.php?departure_label = Dar + Es + Salaam& arrival_label = Zanzibar& txtDate1 = 03%2F19%2F2012& txtDate2 = 03%2F20%2F20%& ddlPAxADT = 1& ddlPaxCHD = 0& ddlPaxINF = 0& search =提交这是我想要的,因为它意味着所有信息都通过了)
它只显示白屏
这是代码
<?PHP
$button = $_GET['submit'];
$search = $_GET['search'];
$sfrom = $_GET['departure_label'];
$sfromda = $_GET['txtdate1'];
$sto = $_GET['arrival_label'];
$stoda = $_GET['txtdate2'];
$padt = $_GET['ddlPaxADT'];
$pchd = $_GET['ddlPaxCHD'];
$pinf = $_GET['ddlPaxINF'];
include "connection.php";
$result=mysql_query("SELECT * from search_v where rout_from like'".$sfrom."' and rout_to like'".$sto."' and DATE_FORMAT(date_avialable,'%Y-%m-%d') between'".$sfromda."' and '".$stoda."' LIMIT 10") or die(mysql_error());
while($runrows = mysql_fetch_assoc($result)){
$flightid = $runrows['flight_id'];
$aseats = $runrows['seats_avialable'];
$todate = strftime("%b %d, %Y %l:%M %p" ,strtotime($runrows['to_date']));
$date = strftime("%b %d, %Y %l:%M %p" ,strtotime($runrows['date_avialable']));
$from = $runrows['rout_from'];
$to = $runrows['rout_to'];
$acost = $runrows['adult_cost'];
$ccost = $runrows['child_cost'];
$cur = $runrows['currency'];
$oth = $runrows['other_cost'];
echo "";
?>
<li class="item clearfix"> <span
id="cntntMiddle_ctl01_rptmain_lblFromt_0">
<table cellpadding="0" cellspacing="0">
<thead><tr>
<th class="price">Price</th>
<th>From</th>
<th>To</th>
<th>Depart</th>
<th>Arrive</th>
</tr>
</thead><tfoot> <tr>
<td><a class="more" href="#">Full
Details</a></td>
<td colspan="6">
<div class="select-wrap">
<p class="seats"><strong><?php echo $aseats; ?></strong> <span>seats
left</span> <em>at this price</em></p>
<button class="btn-select" type="button"
onclick='return ray.ajax("#");'>Select Flight</button></div>
</td>
</tr>
</tfoot><tbody>
<tr>
<td class="price" rowspan="2"><a
style="font-weight: bold; cursor: pointer; text-decoration: none;"
herf="#" onclick='return ray.ajax("#");'><span
style="font-size: 24px; font-weight: bold;"><?php echo $totalcost; ?></span><span
style="font-size: 11px; margin-top: 2px; display: block; color: rgb(255, 255, 255); text-align: center; font-weight: normal;">per
adult</span><span
style="font-size: 12px; margin-top: 2px; display: block; color: rgb(255, 255, 255); text-align: center; font-weight: normal;">(with fees)</span></a></td>
<td><?php echo $from; ?></td>
<td><?php echo $to ?></td>
<td style="padding-right: 2px;">4:05 PM</td>
<td>7:05 PM</td>
</tr>
</tbody>
</table>
</span> <a
id="cntntMiddle_ctl01_rptmain_lblResultDetails1_0" title="1"
href="javascript:__doPostBack('ctl00$cntntMiddle$ctl01$rptmain$ctl00$lblResultDetails1','')"
style="color: Black;"></a><a class="close"
href="#">Close</a>
<div class="info clearfix">
<div class="info clearfix">
<h4>Departing Flight</h4>
<ul class="clearfix">
<li>
<h5><?php echo $from; ?> to <?php echo $to; ?> <?php echo $date; ?></h5>
<ul>
<li> </li>
<li><strong>Flight #</strong> - <?php echo $flightid; ?></li>
<li><strong>Departure Time – </strong>
6:05 PM</li>
<li><strong>Arrival Time</strong> - 5:05 PM</li>
</ul>
</li>
</ul>
<ul>
<li style="padding-top: 5px;"><span
style="color: rgb(212, 22, 13); font-weight: bold; font-size: 11px; text-decoration: none;">
Fare Breakdown</span> </li>
</ul>
<table class="more">
<tbody>
<tr>
<th>Passenger</th>
<th>Fare</th>
<th> Taxes and Fees</th>
<th>Qty</th>
<th>Total Cost</th>
</tr>
</tbody><tbody>
<tr>
<td>Adult</td>
<td
style="color: rgb(100, 100, 100); font-size: 11px; font-weight: bold;"><?php echo $acost; ?></td>
<td><?php echo $oth; ?></td>
<td id="paxAdtTd">1</td>
<td><?php echo $totaladult; ?></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Cost of Sale(<?php echo $cur; ?>)</td>
<td> </td>
<td
style="color: rgb(100, 100, 100); font-size: 14px; font-weight: bold;"><?php echo $totaladult; ?></td>
</tr>
</tbody>
</table>
<br />
<span style="font-weight: bold; padding-top: 10px;">
*Additional airline fees for baggage may apply</span>
<div class="select-wrap">
<p class="seats"><strong><?php echo $aseats; ?></strong> <span>seats
left</span> <em>at this price</em></p>
<button class="btn-select" type="button"
onclick='return ray.ajax("https://res.website.com/checkout.aspx?recommendation=1&subset=1&supplier=53&page=flightconfirm",1,this);'>Select
Flight</button></div>
<?php
}
?>
答案 0 :(得分:0)
$result=mysql_query("SELECT * from search_v where rout_from like %'".$sfrom."'% and rout_to like %'".$sto."'% and DATE_FORMAT(date_avialable,'%Y-%m-%d') between'".$sfromda."' and '".$stoda."' LIMIT 10") or die(mysql_error());
有两个(逻辑?)错误,使用LIKE函数,您没有使用通配符%
键,而在下一个LIKE发生时,对于$sto
,您没有提供空白空间。