Location: PHPKode > scripts > PHP Classified script made easy > php-classified-script-made-easy/openclassifiedsdownload24124/Files/buy.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?PHP include("inc/meta.php"); ?>
<title><?PHP include("inc/title.php"); ?></title>
<link href="inc/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function goto(url)
{
document.location.href=(url);
}
</script>
<style type="text/css">
<!--
.style52 {
	color: #39709B;
	font-weight: bold;
	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 20px;
}
-->
</style>
</head>

<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="53%" height="70" valign="bottom"><a href="index.php"><img src="images/logo.gif" alt="Petoskey Classifieds - Northern Michigan Classifieds" width="450" height="62" border="0" /></a></td>
    <td width="47%" class="head"><div align="right" class="style1"><a href="index.php" class="style46">Home</a> <span class="style4">|</span> <a href="buy.php" class="style10">Buy</a> <span class="style4">|</span><a href="sell.php" class="style46"> Sell </a><span class="style4">| </span><span class="style9"><a href="search.php" class="style46">Search</a> <span class="style44">|</span> <a href="help.php" class="style46">Help</a> </span></div></td>
  </tr>
  <tr>
    <td height="226" colspan="2" valign="top" background="images/bg_buy.png" bgcolor="#F1F5FA" class="left" style="padding-left:150px;"><div align="center"><?PHP include("inc/buy-header-inc.php"); ?></div></td>
  </tr>
  <tr>
    <td height="34" colspan="2" valign="top" class="main-content"><br />
    <table width="100%" height="75" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="71%" valign="top" class="left-content">
		  <?PHP
		  if(isset($_GET['cat'])){
			$category = $_GET['cat'];
			} else { $category = "-1"; }
		  	$subcat  = mysql_query("SELECT * FROM categories WHERE parent = '".$category."'");
			if(mysql_num_rows($subcat) > 0) {
			$rowsn = mysql_num_rows($subcat);
			if($rowsn > 5){
$col = "5";
} else { $col = $rowsn; }
echo' <table width="100%" border="0" cellspacing="3" cellpadding="0" bgcolor="#F1F5FA">
              <tr>
                <td height="26" colspan="'.$col.'" bgcolor="#E2ECF5"><strong>Categories</strong></td>
              </tr><tr>';
			  while($row2 = mysql_fetch_array($subcat, MYSQL_ASSOC))
{
$counter++; // increases by one on each iteration of loop

if (is_float($counter/5)) $split = 1;
else $split = 0; 
if($split == 0){
echo "<td height='48' bgcolor='#F1F5FA' style='padding-top:5px;'><div align='center'><a href='category-".$row2['id'].".php' style='color:#000000;text-decoration:none;'><span style='font-size:20px;'>".$row2['name']."</span><br/><img src='/images/sub-icon.gif' width='55' height='47' border='0' />
                </a></div></td></tr><tr>";
} else { 
echo "<td height='48' bgcolor='#F1F5FA' style='padding-top:5px;'><div align='center'><a href='category-".$row2['id'].".php' style='color:#000000;text-decoration:none;'><span style='font-size:20px;'>".$row2['name']."</span><br/><img src='/images/sub-icon.gif' width='55' height='47' border='0' /></a></div></td>";
}
}
     echo'        </tr>
            </table>';
}
		  ?><table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tbody>
              <tr>
                <td valign="bottom"><span class="style34">Classified Listings</span></td>
                <td width="180" valign="bottom" style="padding-right:5px;"><div align="right"><img src="images/sort.gif" width="80" height="24" /></div></td>
              </tr>
            </tbody>
            </table>
            
            <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #D8D8D8;" class="listings">
              <tr><?PHP

 $pagenum = $_GET['page'];

if (!(isset($pagenum)))

{

$pagenum = 1;

}

 if(isset($_GET['sort'])){$sort = $_GET['sort'];} else { $sort = "date"; }
 if($sort == "date") { $way = "desc";} else { $way = "asc"; }
if(isset($_GET['cat'])){
$category = $_GET['cat'];
			 $query1  = "SELECT * FROM classifieds WHERE cat = '$category' AND authorized = '1'";
} else {
$query1  = "SELECT * FROM classifieds";
 }
              $result1 = mysql_query($query1);
			  $rows = mysql_num_rows($result1);
			  $page_rows = 20;
			  //classifieds into pages... number per page above
			  $last = ceil($rows/$page_rows);
			  
			  if($rows > 0){ 
echo"<td height='30' colspan='2' valign='middle' bgcolor='#E2ECF5' style='padding-left:10px;' class='pages'>";



//Don't Let Our Users Cheat
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}



//This sets the range to display in our query

$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;

if(isset($_GET['sort'])){$sort = $_GET['sort'];} else { $sort = "date"; }
if(isset($_GET['cat'])){
$category = $_GET['cat'];
$query  = "SELECT * FROM classifieds WHERE cat = '$category' AND authorized = '1' ORDER BY ".$sort." ".$way." $max";

} else {
$query  = "SELECT * FROM classifieds WHERE authorized = '1' ORDER BY ".$sort." ".$way." $max";
 }
 $result = mysql_query($query);






echo "<div align='left'>";

// Next and Previous Buttons
if ($pagenum != 1 && $pagenum != $last) {

$previous = $pagenum-1;

$next = $pagenum+1;

echo "<a href='{$_SERVER['PHP_SELF']}?id=50&page=$previous' class='pages'><img src='images/previous.gif' border='0' /></a><a href='{$_SERVER['PHP_SELF']}?id=50&page=$next' class='pages'><img src='images/more.gif' border='0' /></a></div>";

}

elseif ($pagenum == $last)

{

$previous = $pagenum-1;

echo "<a href='{$_SERVER['PHP_SELF']}?id=50&page=$previous' class='pages'><img src='images/previous.gif' border='0' /></a></div> ";

}

elseif ($pagenum == 1)

{

$next = $pagenum+1;

echo " <a href='{$_SERVER['PHP_SELF']}?id=50&page=$next' class='pages'><img src='images/more.gif' border='0' /></a></div> ";

}

else

{

}
echo "</td><td bgcolor='#E2ECF5'><form action='buy.php' method='get' name='frmSort' id='frmSort'>
					"; if($category != "-1") { echo "<input type='hidden' name='cat' value='".$category."' />";} echo"
						<input type='hidden' name='page' value='".$pagenum."' />
                  <select name='sort' size='1' onChange='document.frmSort.submit();'>
                    <option label='Order by...' value='-1' selected='selected'>Sort by...</option>
                    <option label='Name' value='title'>Name</option>
                    <option label='Price' value='price'>Price</option>
                    <option label='Date Listed' value='date'>Date Listed</option>
                  </select>
                </form></td></tr>"; }
				
if($rows > 0){ 				
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$limit++;
$counter++; // increases by one on each iteration of loop

if (is_float($counter/2)) $class = "r2";
else $class = "r1"; 
$description = $row['description'];
$description2 = substr($description,0,130); 
$cat = $row['cat'];
$querya  = "SELECT * FROM categories WHERE id = '$cat' limit 1";
 $resulta = mysql_query($querya);
 while($rowa = mysql_fetch_array($resulta, MYSQL_ASSOC))
{
$catname = $rowa['name'];
}
    echo "
	<tr>
                <td width='16%' class='".$class." thumb'><div align='center'><a href='classified-".$row['adid'].".php'><img src='".$row['picture']."' width='80' height='60' /></a></div></td>
                <td width='70%' height='66' class='".$class." padd'><a href='classified-".$row['adid'].".php' class='style17'>".$row['title']."</a><br />
                  <span class='style36'><em><a href='category-".$cat.".php' style='color:#000000;text-decoration:none;'>".$catname."</a></em><br/>".$description2."...</span></td>
                <td width='14%' class='".$class." price".$class."'><div align='center' class='style28' style='color:#000000;'>$".$row['price']."</div></td>
              </tr>
	
	
	";
}
} else { echo "<div align='center'><h2 style='font-family:Geneva, Arial, Helvetica, sans-serif;color:#2B557B;'><br/>There Are No Classifieds In This Category<br/></h2></div>";}

echo "<div align='left'>";
			  ?>
                </td>
              </tr>
              <tr>
                <td height="23" bgcolor="#E2ECF5" colspan="3"><div align="center">
                    <table width="185" border="0" align="right" cellpadding="0" cellspacing="3">
                      <tr>
                        <td colspan="2"><div align="center" class="style26">
                            <div align="right"><a href="buy.php"></a></div>
                        </div></td>
                      </tr>
                    </table>
                </div></td>
              </tr>
            </table>
            <br />
          <br /></td>
          <td width="29%" valign="top" class="right-content"><?PHP include("inc/right.php"); ?></td>
        </tr>
    </table>    </td></tr>
  <tr>
    <td height="93" colspan="2" valign="top" class="footer">
    <div style="float:right;"><a href="#"><img src="images/backtotop.png" width="59" height="18" border="0" /></a></div>
    <div align="left" class="style23">
      <p><a href="index.php" class="style49">Home</a> <span class="style44">|</span> <a href="buy.php" class="style49">Buy</a> <span class="style44">|</span><a href="sell.php" class="style49"> Sell </a><span class="style44">| </span><span class="style49"><a href="search.php" class="style49">Search</a> <span class="style44">|</span> <a href="help.php" class="style49">Help</a></span></p>
      <p class="style24"> All Rights Reserved
        <?PHP include("inc/title.php"); ?>
          <br />
        PHP Classifieds App - <a href="http://www.rcoders.com/" style="text-decoration:none;color:#000000;">RCoders</a> Dev </p>
    </div></td>
  </tr>
</table>
</body>
</html>
Return current item: PHP Classified script made easy