代码是:
<?php
// my query
if (isset($_GET['ssiptype']))
{
if (($_GET['ssiptype']) == 'gma'){
$query = "SELECT location, year, serviceArea, noOfBenificiaries, stat, fundingSrc, projCost
FROM swipdd
WHERE fundingSrc LIKE 'GMA-Rice%' AND ssiptype = 'SWIP'" ;
}
elseif (($_GET['ssiptype']) == 'am'){
$query = "SELECT location, year, serviceArea, noOfBenificiaries, stat, fundingSrc, projCost
FROM swipdd
WHERE fundingSrc LIKE 'AM-Rice%' AND ssiptype = 'SWIP'" ;
}
elseif (($_GET['ssiptype']) == 'hvcccred'){
$query = "SELECT location, year, serviceArea, noOfBenificiaries, stat, fundingSrc, projCost
FROM swipdd
WHERE fundingSrc LIKE 'HVCC RED%' AND ssiptype = 'SWIP'" ;
}
elseif (($_GET['ssiptype']) == 'hvcc'){
$query = "SELECT location, year, serviceArea, noOfBenificiaries, stat, fundingSrc, projCost
FROM swipdd
WHERE fundingSrc LIKE 'HVCC%' AND ssiptype = 'SWIP'" ;
}
else{}
}
// output
if (isset($query))
{
$result = mysql_query($query) or die(mysql_error());
echo "<table border='1' cellpadding='3'>";
echo "<tr>
<td bgcolor=\"#DFE8EC\">LOCATION</td>
<td bgcolor=\"#DFE8EC\">YEAR</td>
<td bgcolor=\"#DFE8EC\">STATUS</td>
</tr>";
while($row = mysql_fetch_array( $result )) {
$final_result = array_unique($row);
echo "<tr>";
echo '<td>' . $row['location'] . '</td>';
echo '<td>' . $row['year'] . '</td>';
echo '<td>' . $row['stat'] . '</td>';
echo "</tr>";
}
echo "</table>";
}
?>
我想要的输出如下:
//dummy data
LOCATION YEAR STATUS
---------------------------
park 1999 ok
----------------------------
sea 2000 fine
----------------------------
我得到这个输出:
LOCATION YEAR STATUS
----------------------------
park 1999 ok
----------------------------
sea 2000 fine
----------------------------
park 1999 ok
----------------------------
sea 2000 fine
----------------------------
park 1999 ok
----------------------------
sea 2000 fine
----------------------------
它重复了两次。我的代码有什么问题?请,任何帮助将不胜感激。
非常感谢。