我有这个查询在动态表格中显示我的“页面”,但是它显示了所有页面,我想限制“页面”仅在其“campaignid”列与当前“广告系列”列匹配时显示“,任何人都有任何想法。
这是显示数据的查询:
$counter=1; $userID=PageDB::getInstance()->get_user_id_by_name($_SESSION['user']); $result=PageDB::getInstance()->get_pages_by_campaign_id($campaignID);
$i=0;
while ($row = mysqli_fetch_array($result)):
$style = "";
if($i%2==0)
{
$style = ' style="background-color: #EFEFEF"';
}
echo "<tr".$style.">";
echo "<td>" . htmlentities($row['pid']) . "</td>";
echo "<td>". htmlentities($row['id']) . "</td>";
?>
<td>
<form style="display:none;"></form>
<form name="editPage" action="editPage.php" method="GET">
<input type="hidden" name="pageID" value="<?php echo $pageID = $row['pid']; ?>" />
<input type="submit" name="editPage" value="<?php echo "Page " . $counter; ?>" style="padding-top:4px; padding-bottom:6px;background:none;border:none; cursor:pointer"/>
</form>
</td>
<?php
$pageID = $row['pid'];
$counter++;
$i++;
echo "</tr>\n";
endwhile;
mysqli_free_result($result);
?>
以下是我查询数据库的方法。
public function get_pages_by_campaign_id($campaignID) {
$campaignID = $this->real_escape_string($campaignID);
return $this->query("SELECT pid,campaignid,id,campaign_name FROM pages,campaigns WHERE pages.campaignid = campaigns.id ORDER BY campaigns.id LIMIT 1,10");
}
正如我所说它正在返回正确的数据,但我只想显示数据: pages.campaignid = campaigns.id [1]或pages.campaignid = campaigns.id [r]等...
答案 0 :(得分:0)
您需要if-else
循环内的while
条件。如果当前行等于campaigns.id
if-else
语句将进行比较