⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cat_products.php

📁 通达OA部分源代码
💻 PHP
字号:
<?
include_once "myconnect.php";
include_once "date_time_format.php";

if(isset($_REQUEST["cid"]))
{
  $cat_query=mysql_query("Select * from sbbleads_categories where sb_pid=" . $_REQUEST["cid"]);
	$rs=mysql_num_rows($cat_query);
	
	if(($rs<=0)||($_REQUEST["cid"]==0))
	{
	header("Location:"."products.php?cid=".$_REQUEST["cid"]);
	die();
	}

}

function main()
{
$keyword="";
	if(isset($_REQUEST["keyword"])&&($_REQUEST["keyword"]<>""))
	{
		$keyword=$_REQUEST["keyword"];
	}

$config=mysql_fetch_array(mysql_query("select * from sbbleads_config"));
if(($config["sb_image_magik"]=="enable"))
{
$img_path="thumbs1/";
$img_pmt="";
}
else
{
$img_path="uploadedimages/";
$img_pmt="width=".$config["sb_th_width"]." height=".$config["sb_th_width"];
}

$cid=0;
if(isset($_REQUEST["cid"])&&($_REQUEST["cid"]<>""))
{
$cid=$_REQUEST["cid"];
	$sbqu_off="update sbbleads_categories set sb_visit_product=sb_visit_product+1 where sb_id=$cid";
	mysql_query($sbqu_off);
}

/*$sell_num=mysql_num_rows(mysql_query("select * from sbbleads_offers where sb_approved='yes'"));
$buy_num=mysql_num_rows(mysql_query("select * from sbbleads_offers_buy where sb_approved='yes'"));
$product_num=mysql_num_rows(mysql_query("select * from sbbleads_products where sb_approved='yes'"));
$profile_num=mysql_num_rows(mysql_query("select * from sbbleads_companyprofiles where sb_approved='yes'"));*/

	$catname="";
	$category=0;
  
  	$cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $cid );
	if ($cat=mysql_fetch_array($cat_query))
	{
	$catname=$cat["sb_cat_name"];
	$category=$cat["sb_id"];
	}

	$catpath="";
  	$cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $cid );
	while ($rs=mysql_fetch_array($cat_query))
    {
    $catpath =" > <a href=\"cat_products.php?cid=" . $rs["sb_id"] . "\">" .$rs["sb_cat_name"]."</a>".$catpath; 
  	$cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $rs["sb_pid"] );
	 
	}
?> 
<table width="100%" border="0" cellspacing="10" cellpadding="2" class="maintablestyle">
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
        <tr> 
          <form name="form1" method="post" action="search.php">
            <td align="center" valign="middle" class="innertablestyle"><br> <input name="keyword" type="text" value="<? echo $keyword;?>" size="40"> 
              &nbsp;&nbsp; <select name="type">
                <option value="1">Sell Offers</option>
                <option value="2">Buy Offers</option>
                <option value="3" selected>Products Catalogs</option>
                <option value="4">Company Profiles</option>
              </select>
              &nbsp;&nbsp;<font class='normal'>
              <input name="show_save" type="hidden" id="show_save" value="yes">
              </font> 
              <input type="submit" name="Submit" value="Search"> 
              &nbsp;<a href="advance_search.php">Advance Search</a> <br> &nbsp; 
            </td>
          </form>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" >
        <tr> 
          <td><font class="normal">&nbsp;<a href="index.php">Home</a><? echo $catpath;?></font></td>
        </tr>
        <tr> 
          <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="titlestyle">
              <tr> 
                <td align="center" valign="middle" class="subtitle"  >&#8594; 
                  &nbsp;<a href="cat_sell.php<?php if($cid<>0) echo "?cid=".$cid;?>">Sell Offers</a></td>
                <td align="center" valign="middle" class="subtitle" >&#8594; &nbsp;<a href="cat_buy.php<?php if($cid<>0) echo "?cid=".$cid;?>">Buy 
                  Offers</a></td>
                <td align="center" valign="middle" >&#8595; &nbsp;Products</td>
                <td align="center" valign="middle" class="subtitle"  >&#8594; 
                  &nbsp;<a href="cat_profiles.php<?php if($cid<>0) echo "?cid=".$cid;?>">Companies</a></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td valign="top"> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td><font class="normal"><b>Browse Products</b></font></td>
        </tr>
          <td class="onepxtable"><table width="100%" border="0" cellspacing="1" cellpadding="2" class="innertablestyle">
              <?
  
   	$cats_sql="select * from sbbleads_categories where sb_pid=$cid ";
	if($config["sb_cat_listing"]=="alpha")
	{
	$cats_sql.=" order by sb_cat_name";
	}
	else
	{
	$cats_sql.="  order by sb_order_index";
	}
	$cats_query=mysql_query($cats_sql);
	$cnt=1;
	
	while($cats=mysql_fetch_array($cats_query))
	{

		$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid=".$cats["sb_id"] );
		$clist=$cats["sb_id"];
		while ( $rst=mysql_fetch_array($rst_query) )
		{
 				$clist.="," . $rst["sb_id"];
				$thislist="-1," . $rst["sb_id"];
				while ( $rst=mysql_fetch_array($rst_query) )
				{ 
					$clist.="," . $rst["sb_id"];
					$thislist.="," . $rst["sb_id"];
				//echo $rst["sbcat_id"];
				}
	   	$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid in (" . $thislist . ")" );
		}
		
	$sbcat_str= " and  sb_cid IN (" .$clist . ")" ;
	
	$sbq_off_cat="select * from sbbleads_offer_cats, sbbleads_offers where sb_approved='yes' and sbbleads_offers.sb_id=sbbleads_offer_cats.sb_offer_id and DATE_ADD(sb_postedon,INTERVAL ".$config["sb_expiry_sell"]." MONTH) > NOW() $sbcat_str";
	$sboff_count=mysql_num_rows(mysql_query($sbq_off_cat));

	$sbq_buy_cat="select * from sbbleads_offer_cats_buy, sbbleads_offers_buy where sb_approved='yes' and sbbleads_offers_buy.sb_id=sbbleads_offer_cats_buy.sb_offer_id and DATE_ADD(sb_postedon,INTERVAL ".$config["sb_expiry_buy"]." MONTH) > NOW() $sbcat_str";
	$sbbuy_count=mysql_num_rows(mysql_query($sbq_buy_cat));
	
	$sbq_product_cat="select * from sbbleads_product_cats, sbbleads_products where sb_approved='yes' and sbbleads_products.sb_id=sbbleads_product_cats.sb_offer_id $sbcat_str";
	$sbproduct_count=mysql_num_rows(mysql_query($sbq_product_cat));
	
	$sbq_profile_cat="select * from sbbleads_profile_cats, sbbleads_companyprofiles where sb_approved='yes' and sbbleads_companyprofiles.sb_id=sbbleads_profile_cats.sb_profile_id $sbcat_str";
	$sbprofile_count=mysql_num_rows(mysql_query($sbq_profile_cat));

	$sbtotal=$sbproduct_count;//$sboff_count+$sbbuy_count+$sbproduct_count+$sbprofile_count;
//die();
	if($cnt%3==1)
	{
  ?>
              <tr> 
                <td width="20">&nbsp;</td>
                <?
  }
  ?>
                <td align="left"><font class='normal'> <a href="index.php?cid=<? echo $cats["sb_id"];?>"> 
                  </a><a href="cat_products.php?cid=<? echo $cats["sb_id"];?>"><? echo $cats["sb_cat_name"]; ?></a>(<? echo $sbtotal; ?>)</font></td>
                <?
  if($cnt%3==0)
  {
  ?>
              </tr>
              <?
  }
  	$cnt++;
}
?>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
        <tr class="titlestyle"> 
          <td>&nbsp;Featured Products</td>
        </tr>
        <tr>
          <td><table width="100%" cellpadding="2" cellspacing="5">
              <?php
		mt_srand((double)microtime()*1000000);
		
		$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid=".$cid );
		$clist=$cid;
		while ( $rst=mysql_fetch_array($rst_query) )
		{
 				$clist.="," . $rst["sb_id"];
				$thislist="-1," . $rst["sb_id"];
				while ( $rst=mysql_fetch_array($rst_query) )
				{ 
					$clist.="," . $rst["sb_id"];
					$thislist.="," . $rst["sb_id"];
				//echo $rst["sbcat_id"];
				}
	   	$rst_query=mysql_query("Select * from sbbleads_categories where sb_pid in (" . $thislist . ")" );
		}
		$id_list=-1;
		$cat_query=mysql_query("select * from sbbleads_product_cats where sb_cid in ($clist)");
		while($offer_cat=mysql_fetch_array($cat_query))
		{ $id_list.=",".$offer_cat["sb_offer_id"];}
		$sbq1_mem="select * from sbbleads_members where sb_memtype=1";
		$sbrs1_mem=mysql_query($sbq1_mem);
		$sbgold_list="0";
		while($sbrow1_mem=mysql_fetch_array($sbrs1_mem))
		{
			$sbgold_list.=",".$sbrow1_mem["sb_id"];
		}

	$sbq_off="select *,UNIX_TIMESTAMP(sb_postedon) as ondate from sbbleads_products 
	where sb_approved='yes' and sb_uid in ($sbgold_list)  and sb_id in ($id_list)  order by sb_id desc";
	//echo $sbq_off;
	$sbrs_off=mysql_query($sbq_off); 
	$num_rows=mysql_num_rows($sbrs_off);
	$max_allowed=$config["sb_cat_featured"];

	$number[0]=-1;
	if($num_rows>$max_allowed)
	{
		for($i=0;$i<$max_allowed;$i++)
		{
			$unique=0;
			while($unique==0)
			{
				$j=rand(0,$num_rows-1);
				for($k=0;$k<count($number);$k++)
				{
					//echo $j;
					if($number[$k]==$j)
					break;
				}
				if($k>(count($number)-1))
				{
					$unique=1;
				}
			}
			$number[$i]=$j;
					
		}
	}// end if num > no_allowed
					/*for($k=0;$k<count($number);$k++)
							{
								echo $number[$k]." ";
							}*/
	$row=0;
	$cnt=0;
	$offer=mysql_fetch_array($sbrs_off);
	while (($offer)&&($cnt<$max_allowed))
	{ 
		$display=0;
		if($num_rows>$max_allowed)
		{
			for($k=0;$k<count($number);$k++)
			{
				if($number[$k]==$row)
				{
					$display=1;
				}
			}
		}
		else
		{
			$display=1;
		}
		if($display==1)
		{
		$images=mysql_fetch_array(mysql_query("select * from sbbleads_product_images where sb_offer_id=".$offer["sb_id"]." order by sb_id"));

		  ?>
              <tr > 
                <td valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="60" rowspan="3" align="center" valign="top"> 
                        <? if ($images) {echo "<a href=\"view_product.php?id=".$offer["sb_id"]."\" ><img  $img_pmt border=0 src=\"$img_path" .$images["sb_img_url"]."\"></a>"; }  else
			   {
			   ?>
                        <img src="images/nopic.gif" <? echo $img_pmt; ?>> 
                        <?
			  }?>
                      </td>
                      <td class="subtitle"><font class="normal">&nbsp;<a 
                                href="view_product.php?id=<?php echo $offer["sb_id"];?>"> 
                        <?php
					if (strlen ($offer["sb_title"])>50)
					{
					 echo substr($offer["sb_title"], 0,  strrpos( substr($offer["sb_title"], 0, 50),' ' ));  
					}
					else
					{
					 echo $offer["sb_title"];  
					}
					?>
                        </a><font class="red"> [ 
                        <?
				  $cur=mysql_fetch_array(mysql_query("select * from sbbleads_currencies where sbcur_id=".$offer["sb_price_cur_id"]));
				  echo $cur["sbcur_symbol"];
								?>
                        <?php echo $offer["sb_price"];?>]</font></font></td>
                    </tr>
                    <tr> 
                      <td><font class="smalltext"> &nbsp;Posted by <strong> 
                        <?php 
				  $mem=mysql_fetch_array(mysql_query("select * from sbbleads_members where sb_id=".$offer["sb_uid"]));
				  $profile=mysql_fetch_array(mysql_query("select * from sbbleads_companyprofiles where sb_uid=".$offer["sb_uid"]));
				  
				  if ($profile) { echo $profile["sb_companyname"];} 
				  else {  echo $mem["sb_username"]; }
				  ?>
                        </strong><font class="red"><strong>[ 
                        <?php  
			$level_query=mysql_query("select * from sbbleads_levels where sb_levelid=" .$mem["sb_memtype"]);
            $level= mysql_fetch_array($level_query);
			echo $level["sb_levelname"];
			?>
                        ]</strong></font> on <?php echo sb_date($offer["ondate"]);?> 
                        </font></td>
                    </tr>
                    <tr> 
                      <td valign="top"><font class="smalltext"> &nbsp; 
                        <?php
					if (strlen (strip_tags($offer["sb_description"]))>100)
					{
					 echo substr(strip_tags($offer["sb_description"]), 0,  strrpos( substr(strip_tags($offer["sb_description"]), 0, 100),' ' )) . "..";  
					}
					else
					{
					 echo strip_tags($offer["sb_description"]);  
					}
					?>
                        </font></td>
                    </tr>
                  </table></td>
              </tr>
              <?
		$cnt++;
		}//if display
		$offer=mysql_fetch_array($sbrs_off);
		/*if(!$offer||($cnt>=$max_allowed))
		{
		?>
              <tr>
                <td valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="60">&nbsp;</td>
                      <td class="subtitle"><font class="red"><strong>Default Ad 
                        </strong></font><font class="normal">&nbsp;</font></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                      <td><font class="smalltext">Become a Gold member and your 
                        Offer will appear here. </font></td>
                    </tr>
                  </table></td>
              </tr>
              <?
		}*/
		$row++;
	}// end while	  
		  ?>
              <tr>
                <td valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td class="subtitle"><font class="red"><strong>Default Ad 
                        </strong></font><font class="normal">&nbsp;</font></td>
                    </tr>
                    <tr> 
                      <td><font class="smalltext">Become a Gold member and your 
                        Offer will appear here. </font></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<?
}// end main
include "template.php";
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -