

<?

$query="select * from auction_details where status='Active' and selling_method='ads' and picture1!='' ";

$tab=mysql_query($query);

$count=mysql_num_rows($tab);

//checking and display ads if any ads are shopd.

if($count!=0)

{



$ads[1]=rand(1,$count);



if($count>=2)

{

   while($ads[2]=rand(1,$count))

   {

     if($ads[2]!=$ads[1])

     break;

   }

}



if($count>=3)

{

   while($ads[3]=rand(1,$count))

   {

     if( ($ads[3]!=$ads[1]) && ($ads[3]!=$ads[2]) )

     break;

   }

}



if($count>=4)

{

   while($ads[4]=rand(1,$count))

   {

     if( ($ads[4]!=$ads[1]) && ($ads[4]!=$ads[2]) && ($ads[4]!=$ads[3]))

     break;

   }

}

//if there are less than 4 picture ads are available in database

//then this code will excute.

/*echo count($ads);

if( (count($ads)<4) && (count($ads) >0) )

{

 echo   $k=count($ads);

echo  $w=$k;

  for($i=$k;$i<=4;$i++,$w++)

  {

    $ads[$i] = $ads[$w];

  }

}

echo count($ads);

*/

?>

<table border="0" align="center" cellpadding="5" cellspacing="0" width="100%" clas="table_border1_with_bg" background="templates/<? echo "$tfold" ?>/img_files/window.gif" >

<!--	<tr >

	<td clas="tdhead" height="30" valign="middle" colspan="4">&nbsp;&nbsp;

	&nbsp;&nbsp;Classifide Ads</td></tr> -->

	

<?

$v=0;

$tr=0;

while($row=mysql_fetch_array($tab))

{

$v++;

  if( ($v==$ads[1])|| ($v==$ads[2])|| ($v==$ads[3]) || ($v==$ads[4]) )

  {

  }

  else

  {

  continue;

  }

$tr++;

?>

<?  	if($tr%2==1) echo "<tr height=150 >"; ?>

<td width="50%" valign="middle" align="center"	 ><br>



<? if(empty($row['picture1']))

	{ ?>

		<a href="classifieds.php?productid=<? echo $row['productid']; ?>">

		<img src="templates/<? echo "$tfold" ?>/img_files/no-image.gif" width=80 height=80 border=1></a>

	<?

	}

	else

	{

	               $img=$row['picture1'];

				   list($width, $height, $type, $attr) = getimagesize("uploads/$img");

				   $h=$height;

				   $w=$width;

				   if($h>80)	

				   {

				   $nh=80;

				   $nw=($w/$h)*$nh;

				   $h=$nh;

				   $w=$nw;

				   }

				  if($w>80)

				  {

				  $nw=80;

				  $nh=($h/$w)*$nw;

				  $h=$nh;

				  $w=$nw;

				  }

	

	?>

	 <a href="classifieds.php?productid=<? echo $row['productid']; ?>">

	 <img src="uploads/<? echo $row['picture1']; ?>" width=<?= $w; ?> height=<?=$h?>  border=0>

	 </a>

	<? 

	}

	?>

	<br>

<a href="classifieds.php?productid=<? echo $row['productid']; ?>">

<u><font color="#000066"><b><?= $row['producttitle']; ?></b></font></u>

</a>

<br>







</td>



<?  if($tr%2==2) echo"</tr>"; ?>



<?

}

?>



</table>

<table><tr><td width="300" align="right"><a href="all_classifieds.php"><strong>More</strong> </a></td></tr></table>



<?

}

?>