<?php
/***************************************************************************
 *                              popular_prod.php		           *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *	
 *   File Info:		  Lists most popular 10 products                   *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 *   This file is used for testing the links for product item. It will not *
 *   appear on your e-commerce site.					   *
 ***************************************************************************/

include("./config.php");
$table = "rating";
$ratesql = "SELECT * from $table  order by rating desc LIMIT 10";
$rate = @mysql_query($ratesql,$conn)
	or die("Unable to find product id from rating table...");
$rrow = mysql_num_rows($rate);

if ($rrow > 0)
{
	$no = 0;
	// start table for neat display
	echo"<b><font face = Verdana size = 3 color = $color><center>Most Popular Products</center></font></b><hr></center><table align=\"left\" width=\100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
				
	while($row = mysql_fetch_array($rate)){ 
						
	$pid=$row["pid"];
						
	$item = $row["item"];
	$item=substr($item,0,45);							
	$no = $no + 1;
	// display info
	echo"<tr><td align=\"left\"><b>$no.  </b></td><td align=\"left\"><a href=\"shop_showitem.php?pid=$pid\">  $item";
	// display .. if title is longer that 13 chars
	if(strlen($item)>= 45)
	{echo"..";}
					
	echo"</a></td></tr>";
					
	}// end while
	echo"</table></center><br><br>";
}
?>