'$cat' is a variable from the search form on the previous page.
Here is the complete query page:
Code: Select all
<?php require_once('Connections/cds.php'); ?>
<?php
$db_connection = mysql_connect($hostname_cds , $username_cds , $password_cds) or die ("Could not connect to database");
mysql_select_db ($database_cds , $db_connection) or die ("Could not find database")
?>
<script language="JavaScript" type="text/JavaScript">
function openWindow(theURL,winName,features)
{
window.open(theURL,winName,features);
}
</script>
<?php
/* HEADER STUFF*/
echo "<title>Search Results</title>";
echo "<link href="styles/stylefile.css" rel="stylesheet" type="text/css">";
echo "<body bgcolor="#2B5796" leftmargin="0" topmargin="0">";
echo "<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">";
echo "<tr>";
echo "<td align="center" valign="middle">";
/*--TABLE START--*/
echo "<table border="0" cellpadding="0" cellspacing="0" class="table">";
echo "<tr>";
echo "<td class="top">Search Results</td>";
echo "<td align="right" class="top"><a href="">New Search</a>><a href="crossroad.php?id=".$id."">Home</a>><a href="index.php">index</a></td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan="2" valign="top" align="center">";
/*Next-Previous Settings*/
if(!isset($start)) $start = 0;
$next=$start + 15;
$prev=$start + 15;
$end=15;
if ($s == "pw")
{
if ($domain <> "")
{
echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">";
echo "<tr valign="top">";
echo "<td width="35%">Website Title</td><td width="35%">Username</td><td width="25%">Password</td><td width="5%"></td>";
echo "</tr>";
$color1 = "#F5F5F5";
$color2 = "#FFFFFF";
$row_count = 0;
$query = "SELECT * FROM pw WHERE (title LIKE '%$domain%') LIMIT ".$start.", ".$end."";
$result = mysql_query ($query, $db_connection) or die("SELECT Error [$query]:".mysql_error());
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_object ($result))
{
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<tr class="middle" valign="top">";
echo "<td bgcolor="$row_color"><a href="".$row->url."" target="_blank">" . $row->title . "</a></td>";
echo "<td bgcolor="$row_color">" . $row->user . "</a></td>";
echo "<td bgcolor="$row_color">" . $row->pass . "</td>";
echo "<td bgcolor="$row_color"></td>";
echo "</tr>";
$row_count++;
}
echo "</td>";
echo "</tr>";
echo "<tr valign="bottom" align="center">";
echo "<td align="center" colspan="4">";
//second script added for navigation
$query = "SELECT count(*) FROM pw WHERE (pw.url LIKE '%$domain%')";
$result = mysql_query($query , $db_connection) or die("SELECT Error [$query]:".mysql_error());
$numrows = array_shift(mysql_fetch_row($result));
if($start > 0)
{
echo "| <a href="" . $PHP_SELF . "?start=" . $prev . "">Previous</a> |";
}
if($numrows > ($start + $end) )
{
echo "| <a href="" . $PHP_SELF . "?start=" . $next . "">Next</a> |";
}
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td height="10" colspan="3" class="bottom">There are ".$num_rows." results in your query</td>";
echo "</tr>";
echo "</table>";
}
}
if ($s == "cd")
{
if (($title <> "")||($company <> ""))
{
echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">";
echo "<tr valign="top">";
echo "<td width="40%">Title</td><td width="35%">CD</td><td width="20%">Category</td><td width="5%">Status</td>";
echo "</tr>";
$color1 = "#F5F5F5";
$color2 = "#FFFFFF";
$row_count = 0;
$query = "SELECT * FROM cd, sw, cat WHERE (sw.sw_title LIKE '%$title%' AND sw.company LIKE '$company%') AND sw.cat_id LIKE cat.cat_id AND sw.cd_id LIKE cd.cd_id ORDER BY sw_title ".$order." LIMIT ".$start.", ".$end."";
$result = mysql_query ($query, $db_connection) or die("No records found");
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_object ($result))
{
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<tr class="middle" valign="top">";
echo "<td bgcolor="$row_color"><a href="#" onClick="openWindow('sw_info.php?id=" . $row->sw_id . "','','scrollbars=yes,width=500,height=350')">" . $row->sw_title . "</a></td>";
echo "<td bgcolor="$row_color"><a href="#" onClick="openWindow('cd_info.php?id=" . $row->cd_id . "','','scrollbars=yes,width=500,height=500')">" . $row->cd_title . "</a></td>";
echo "<td bgcolor="$row_color">" . $row->cat_title . "</td>";
echo "<td><a href="status.php?id=" . $row->cd_id . "" onClick="OpenWindow"><img src="images\s" . $row->io . ".jpg " border="0"></a></td>";
echo "</tr>";
$row_count++;
}
echo "</td>";
echo "</tr>";
echo "<tr valign="bottom" align="center">";
echo "<td colspan="2">";
//second script added for navigation
$query = "SELECT count(*) FROM cd, sw, cat WHERE (sw.sw_title LIKE '%$title%' AND sw.company LIKE '$company%') AND sw.cat_id LIKE cat.cat_id AND sw.cd_id LIKE cd.cd_id";
$result = mysql_query($query , $db_connection) or die("SELECT Error [$query]:".mysql_error());
$num_rows = array_shift(mysql_fetch_row($result));
if($start > 0)
{
echo "| <a href="" . $PHP_SELF . "?start=" . $prev . "">Previous</a> |";
}
if($num_rows > ($start + $end))
{
echo "| <a href="" . $PHP_SELF . "?start=" . $next . "">Next</a> |";
}
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td height="10" colspan="3" class="bottom">There are ".$num_rows." results in your query</td>";
echo "</tr>";
echo "</table>";
exit;
}
if ($disc <> "")
{
echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">";
echo "<tr valign="top">";
echo "<td width="650">CD</td><td width="50">Status</td>";
echo "</tr>";
$color1 = "#F5F5F5";
$color2 = "#FFFFFF";
$row_count = 0;
$category_query = "SELECT * FROM cd WHERE (cd.cd_title LIKE '$disc%') ORDER BY cd_title ".$order." LIMIT ".$start.", ".$end."";
$result = mysql_query ($category_query, $db_connection) or die("No records found");
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_object ($result))
{
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<tr class="middle" valign="top">";
echo "<td bgcolor="$row_color"><a href="#" onClick="openWindow('cd_info.php?id=" . $row->cd_id . "','','scrollbars=yes,width=500,height=500')">" . $row->cd_title . "</a></td>";
echo "<td><a href="status.php?id=" . $row->cd_id . "" onClick="OpenWindow"><img src="images\s" . $row->io . ".jpg " border="0"></a></td>";
echo "</tr>";
$row_count++;
}
echo "</td>";
echo "</tr>";
echo "<tr valign="bottom" align="center">";
echo "<td colspan="2">";
//second script added for navigation
$query = "SELECT count(*) FROM cd WHERE (cd.cd_title LIKE '$disc%')";
$result = mysql_query($query , $db_connection) or die("SELECT Error [$query]:".mysql_error());
$num_rows = array_shift(mysql_fetch_row($result));
if($start > 0)
{
echo "| <a href="" . $PHP_SELF . "?start=" . $prev . "">Previous</a> |";
}
if($num_rows > ($start + $end))
{
echo "| <a href="" . $PHP_SELF . "?start=" . $next . "">Next</a> |";
}
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td height="10" colspan="2" class="bottom">There are ".$num_rows." results in your query</td>";
echo "</tr>";
echo "</table>";
}
if ($cat <> "")
ini_set('display_errors', TRUE);
error_reporting(TRUE);
{
echo "<table width="100%" border="0" cellspacing="0" cellpadding="0">";
echo "<tr valign="top">";
echo "<td width="40%">Title</td><td width="35%">CD</td><td width="20%">Category</td><td width="5%">Status</td>";
echo "</tr>";
$color1 = "#F5F5F5";
$color2 = "#FFFFFF";
$row_count = 0;
$query = "SELECT * FROM cd, sw, cat WHERE (sw.cat_id LIKE '$cat') AND sw.cat_id LIKE cat.cat_id AND sw.cd_id LIKE cd.cd_id ORDER BY sw_title ".$order." LIMIT ".$start.", ".$end."";
$result = mysql_query($query , $db_connection) or die("SELECT Error [$query]:".mysql_error());
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_object ($result))
{
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<tr class="middle" valign="top">";
echo "<td bgcolor="$row_color"><a href="#" onClick="openWindow('sw_info.php?id=" . $row->sw_id . "','','scrollbars=yes,width=500,height=350')">" . $row->sw_title . "</a></td>";
echo "<td bgcolor="$row_color"><a href="#" onClick="openWindow('cd_info.php?id=" . $row->cd_id . "','','scrollbars=yes,width=500,height=500')">" . $row->cd_title . "</a></td>";
echo "<td bgcolor="$row_color">" . $row->cat_title . "</td>";
echo "<td bgcolor="$row_color"><a href="status.php?id=" . $row->cd_id . "" onClick="OpenWindow"><img src="images\s" . $row->io . ".jpg " border="0"></a></td>";
echo "</tr>";
$row_count++;
}
echo "</td>";
echo "</tr>";
echo "<tr valign="bottom" align="center">";
echo "<td colspan="2">";
//second script added for navigation
$query = "SELECT count(*) FROM cd, sw, cat WHERE (sw.cat_id LIKE '$cat') AND sw.cat_id LIKE cat.cat_id AND sw.cd_id LIKE cd.cd_id";
$result = mysql_query($query , $db_connection) or die("SELECT Error [$query]:".mysql_error());
$num_rows = array_shift(mysql_fetch_row($result));
if($start > 0)
{
echo "| <a href="" . $PHP_SELF . "?start=" . $prev . "">Previous</a> |";
}
if($num_rows > ($start + $end))
{
echo "| <a href="" . $PHP_SELF . "?start=" . $next . "">Next</a> |";
}
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan="4">";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td height="10" colspan="3" class="bottom">There are ".$num_rows." results in your query</td>";
echo "</tr>";
echo "</table>";
}
}
echo "</td>";
echo "</tr>";
echo "</table>";
?>