This is my php code, I was wondering if you could help me,
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="script.js"></script>
<?php $cat = mysql_real_escape_string($_GET['category']);
include '../includes/db-conns.php';
//The file is being accessed on the staging site
$hostname = $hostname3;
$username = $username2;
$password = $password2;
$databasename = $databasename3;
$link = mysql_connect($hostname, $username, $password);
mysql_select_db($databasename, $link);
//sets encode to utf8
mysql_query("set names utf8");
ini_set ("display_errors", "on");
//ini_set ("error_reporting", 6143);
$query = "SELECT * FROM 100_people WHERE '$cat' IN (ppl_cat1,ppl_cat2,ppl_cat3,ppl_cat4,ppl_cat5,ppl_cat6,ppl_cat7,ppl_cat8,ppl_cat9,ppl_cat10,ppl_cat11,ppl_cat12) ORDER BY ppl_id ASC";
$result = mysql_query($query) or die(mysql_error());
?> <?php /*?>Navigation Loop<?php */?>
<TABLE cellpadding="0" cellspacing="0" border="0" class="sortable" id="sorter">
<tr class="nosort">
<td>Rank</td>
<td class="nosort">Image</td>
<td class="nosort">Name</td>
<td class="nosort">Title</td>
<td class="nosort">Category</td>
</tr>
<?
while ($row = mysql_fetch_assoc ($result)) {
echo "<TR>\n";
echo "<td>" . $row['ppl_id'] . "</td><td><img src='http://defensenews.com/assets/100people/" .$row['ppl_image']."' width='50px'/></td><td><a href='www.defensenews.com/100people/person?vip=". $row['ppl_id'] . "'>" . $row['ppl_name']."</a></td><td>" . $row['ppl_title'] . "</td>\n";
?>
<td><?php if ($row['ppl_cat1']){
echo '<a href="www.defensenews.com/people/category?category='. $row['ppl_cat1'].' ">'. $row['ppl_cat1'].'</a>'; }
if ($row['ppl_cat2']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat2'].' ">'. $row['ppl_cat2'].'</a>'; }if ($row['ppl_cat3']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat3'].' ">'. $row['ppl_cat3'].'</a>'; }if ($row['ppl_cat4']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat4'].' ">'. $row['ppl_cat4'].'</a>'; }if ($row['ppl_cat5']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat5'].' ">'. $row['ppl_cat5'].'</a>'; }if ($row['ppl_cat6']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat6'].' ">'. $row['ppl_cat6'].'</a>'; }if ($row['ppl_cat7']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat7'].' ">'. $row['ppl_cat7'].'</a>'; }if ($row['ppl_cat8']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat8'].' ">'. $row['ppl_cat8'].'</a>'; }if ($row['ppl_cat9']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat9'].' ">'. $row['ppl_cat2'].'</a>'; }if ($row['ppl_cat9']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat10'].' ">'. $row['ppl_cat10'].'</a>'; }if ($row['ppl_cat11']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat11'].' ">'. $row['ppl_cat11'].'</a>'; }if ($row['ppl_cat12']){
echo ', <a href="www.defensenews.com/people/category?category='. $row['ppl_cat12'].' ">'. $row['ppl_cat12'].'</a>'; }?></td>
<?php
echo "</TR>\n";
}
echo "</TABLE>\n";
?>
<script type="text/javascript">
var sorter=new table.sorter("sorter");
sorter.init("sorter",1);
</script>
When I run this, If I run the query in phpMyAdmin it works fine. But if I use this on my page Id returns all records not ust the records that have $cat in one of the 12 columns. Any Ideas on what I am doing wrong. I have tried removing the single quotes from around my variable but no dice.
Thanks,