我在这里结束了我的目击。 我有一张餐桌上的反馈数据,我正在创建一个用户可以过滤的记分卡网站
在提交过滤器和构建查询之后,我试图在表中显示数据,但问题是表本身从未生成...
我怀疑在获取行时出错,但似乎无法找到问题。
while ($row = mysqli_fetch_row($result))
{
$mcount = $row['ID'];
$mydata = stats("ALLMYRECORDS", "ALLMYRECORDS", "ALLMYRECORDS", "$property", "$outlet", "$pickyear",$mysqli);
请欣赏一些帮助,因为我是MySQLi部分新手,不知道该怎么做。谢谢。
<?php
$property = $_POST['table_select'];
$outlet = $_POST['outlet_select'];
$pickyear = $_POST['year_select'];
$_SESSION['property'] = "$property";
$_SESSION['outlet'] = "$outlet";
$_SESSION['pickyear'] = "$pickyear";
?>
<table width="100%">
<?php
if ((isset($propery)) && (isset($outlet)) && (isset($pickyear))) {
echo "<tr><td><strong>No Selection Criteria</strong></td></tr>";
}
else {
echo " <tr><td bgcolor=\"#3F4039\">
<p class=\"sansserif\"><b>RESULTS FOR: $property - $outlet - $pickyear</b></p>
</td></tr>";
}
?>
</table>
<table width="100%">
<?php
if ((isset($property)) && (isset($outlet)) && (isset($pickyear))) {
echo "<tr><td><strong>No Selection Criteria</strong></td></tr>";
}
else {
echo " <tr><td bgcolor=\"#3F4039\">
<p class=\"sansserif\"><br><b>SCORE BREAKDOWN BY CATEGORY - $outlet</b></p>
</td></tr>";
}
?>
</table>
<table class="fb_feedback_results" width="950px">
<?php
// multiple criteria selection
$whereParts = array();
if ($property) {
$whereParts[] = "Holidex = '$property' ";
}
if ($outlet) {
$whereParts[] = "Outlet = '$outlet' ";
}
if ($pickyear) {
$whereParts[] = "YEAR(date) = '$pickyear' ";
}
$sql = ("SELECT COUNT(ID) AS MCOUNT FROM FB_Feedback_Card_Data");
//BUILD THE FINAL QUERY
if (count($whereParts) > 0) {
$sql .= " WHERE " . implode('AND ', $whereParts);
}
//count($whereParts) > 0
$result = $mysqli->query($sql) or die('<p>Query to get total data from FB_Feedback_Card_Data table failed:' . mysql_error() . '</p>');
while ($row = mysqli_fetch_row($result))
{
$mcount = $row['ID'];
$mydata = stats("ALLMYRECORDS", "ALLMYRECORDS", "$property", "$pickyear",$mysqli);
?>
<tr>
<th class="header">Item</th>
<th class="header">Jan</th>
<th class="header">Feb</th>
<th class="header">Mar</th>
<th class="header">Apr</th>
<th class="header">May</th>
<th class="header">Jun</th>
<th class="header">Jul</th>
<th class="header">Aug</th>
<th class="header">Sep</th>
<th class="header">Oct</th>
<th class="header">Nov</th>
<th class="header">Dec</th>
<th class="header">YTD</th>
</tr>
<tr>
<td class="result_desc">Ttl. No. of Feedback</td>
<td class="result" align=center><?echo $mydata['a'];?></td>
<td class="result" align=center><?echo $mydata['b'];?></td>
<td class="result" align=center><?echo $mydata['c'];?></td>
<td class="result" align=center><?echo $mydata['d'];?></td>
<td class="result" align=center><?echo $mydata['e'];?></td>
<td class="result" align=center><?echo $mydata['f'];?></td>
<td class="result" align=center><?echo $mydata['g'];?></td>
<td class="result" align=center><?echo $mydata['h'];?></td>
<td class="result" align=center><?echo $mydata['i'];?></td>
<td class="result" align=center><?echo $mydata['j'];?></td>
<td class="result" align=center><?echo $mydata['k'];?></td>
<td class="result" align=center><?echo $mydata['l'];?></td>
<td class="result_ytd" align=center><strong><?echo $mydata['total'];?></strong></td>
</tr>
<?php
// end grand total stats
}
?>
</table>