I have this query which shows my "pages" in a dynamic table, however it shows all of the pages, I want to limit the "pages" to show only if their "campaignid" column matches that of the current "campaign", would anyone have any ideas.
This is the query that displays the data:
$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>
";
endwhile;
mysqli_free_result($result);
?>
And here is how I am querying the database.
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");
}
As I said it is returning the right data, but I only want to display the data where: pages.campaignid = campaigns.id [1] or pages.campaignid = campaigns.id [r] etc...