This is how I've coded it; however, when I try to run the query, I get no results.
$sql = <<<EOS
SELECT pro.prg_id as id, pro.name as name, pro.clickbank as clickbank,
pro.cost as cost, pro.summary as summary, cat.cat_name as category,
type.type_name as type
FROM legit_programs pro
LEFT JOIN legit_type type
ON pro.type = type.type_id
LEFT JOIN legit_cat cat
ON pro.category = cat.cat_id
WHERE
EOS;
if(isset($_GET['name'])) {
$sql .= "MATCH (name) AGAINST ('" . htmlspecialchars($_GET['name']) . "' IN BOOLEAN MODE)";
if(isset($_GET['type'])) {
$sql.= " AND ";
} else if(isset($_GET['cat'])) {
$sql.= " AND ";
} else if(isset($_GET['cost'])) {
$sql.= " AND ";
}
} else {}
if(isset($_GET['type'])) {
$sql .= "type='" . $_GET['type'] . "'";
if(isset($_GET['cat'])) {
$sql .= " AND ";
} else if(isset($_GET['cost'])) {
$sql .= " AND ";
}
} else {}
if(isset($_GET['cat'])) {
$sql .= "category='" . $_GET['cat'] . "'";
if(isset($_GET['cost'])) {
$sql .= " AND ";
}
} else {}
if(isset($_GET['cost'])) {
$sql .= "cost " . $_GET['cost'];
} else {}
$sql .= "AND pro.is_published=1;";
$result = mysql_query($sql, $conn)
or die('Could not retrieve review data;' . mysql_error());
?>
<h1>Search Results</h1>
<table id="revresults">
<tr>
<th>Name</th>
<th>Type</th>
<th>Category</th>
<th>Summary</th>
<th>Cost</th>
</tr>
<?php
if(mysql_num_rows($result) == 0) {
echo "<tr><td colspan=5><em>No reviews available</em></td></tr>";
} else {
while ($row = mysql_fetch_array($result)) {
echo "<tr>\n";
echo '<td><a href="reviews.php?id=' . $row['id'] . '">' . $row['name'] . "</a></td>\n";
echo "<td>" . $row['type'] . "</td>\n";
echo "<td>" . $row['category'] . "</td>\n";
echo "<td>" . $row['summary'] . "</td>\n";
echo "<td>" . $row['cost'] . "</td>\n";
echo "</tr>";
}
}
echo "</table>"
?>