我有这个查询,它在动态表中显示我的“页面”,但是它显示了所有页面,我想限制“页面”仅在其“活动 ID”列与当前“活动”列匹配时显示,将有人有想法么。
这是显示数据的查询:
$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 =campaign.id [1] 或 pages.campaignid =campaigns.id [r] 等...