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

📄 favorites_cats.php

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

$to_delete="";
$items_removed=0;
if ( count($_POST)<>0 )
{


/////////////////////////// A REQUEST TO DELETE SOME CONTACTS ///////////////
if(isset($_REQUEST["delete"]))
{
	for($i=0;$i<=$_REQUEST["cnt"];$i++)
	{
	 
	if ( isset($_REQUEST["checkbox" . $i]) )  //Is the checkbox ticked
	{
	if ($to_delete!="") { $to_delete.="," ; }  //To insert comma??
	$to_delete.= $_REQUEST["checkbox" . $i];  //Add another item to delete
	$items_removed++;
	}
	
	} //End For
	
	
	if ($to_delete=="")
	{
		$msg1="Please choose a category";
	}
	else
	{
		$del_str="  Delete from sbbleads_fav_cats where id IN (" . $to_delete .")";
	//echo $del_str; 
	mysql_query($del_str);
	$msg1= $items_removed;
	$msg1.=($items_removed>1)?' Categories have':' Category has';
	$msg1.=" been removed";
	}
}		//edn if delete
//=============insert
if(isset($_REQUEST["insert"]))
{
	$sb_cid=(int)$_REQUEST["cat1"];
	$sb_uid=$_SESSION["sbbleads_userid"];
	if($sb_cid==0)
	{
			header("Location: other_confirm_mem.php?err=favorites_cats&errmsg=".urlencode("
			Please choose a category to add."));
			die();
	}
	if($_REQUEST["sb_type"]<>0)
	{

		switch($_REQUEST["sb_type"])
		{
		  case 1: $sb_type="sell"; break;
		  case 2: $sb_type="buy"; break;
		  case 3: $sb_type="product"; break;
		  case 4: $sb_type="profile"; break;
		}
		$check_fav=mysql_fetch_array(mysql_query("select * from sbbleads_fav_cats where mid=$sb_uid 
		and cid=$sb_cid and sb_type='$sb_type'"));

		if($check_fav)
		{
		$msg1="Requested category is already in your favorite list";
		}
		else
		{
		mysql_query("insert into sbbleads_fav_cats (mid,cid,sb_type) 
		values ($sb_uid,$sb_cid,'$sb_type') ");
			if(mysql_affected_rows()>0)
			{
			$msg1="Requested category has been added to your favorite list";
			}
			else
			{
			header("Location: other_confirm_mem.php?err=favorites_cats&errmsg=".urlencode("
			Sorry, some error occurred and unable to add category to your favourite list"));
			die();
			}
		}//inserted single
	} //end if sb_type<>0
	else
	{
		$cnt=0;
		for($i=1;$i<=4;$i++)
		{
		switch($i)
		{
		  case 1: $sb_type="sell"; break;
		  case 2: $sb_type="buy"; break;
		  case 3: $sb_type="product"; break;
		  case 4: $sb_type="profile"; break;
		}
		
		$check_fav=mysql_fetch_array(mysql_query("select * from sbbleads_fav_cats where mid=$sb_uid 
		and cid=$sb_cid and sb_type='$sb_type'"));
		if($check_fav)
		{
		continue;
		}
		
		mysql_query("insert into sbbleads_fav_cats (mid,cid,sb_type) 
		values ($sb_uid,$sb_cid,'$sb_type') ");
		$cnt++;
		}
		if(mysql_affected_rows()>0)
		{
		$msg1=$cnt." category(ies) have been added to your favorite list";
		}
		else
		{
			header("Location: other_confirm_mem.php?err=favorites_cats&errmsg=".urlencode("
			Sorry, some error occurred and unable to add category to your favourite list"));
			die();
		}
	}// end sb_type==0
}	//end if insert
header("Location: other_confirm_mem.php?errmsg=".urlencode($msg1));
die();
/////////////////////////////
}



function main()
{
	global $to_delete, $items_removed;
?>
<script language="JavaScript">
//<!--
function category(box)
{

str="choosecategory.php?box="  + box;

window.open(str,"Category","top=5,left=30,toolbars=no,maximize=yes,resize=yes,width=550,height=450,location=no,directories=no,scrollbars=yes");


}
function validate(form)
{
if(form.cat1.value=="")
{
alert('Please choose a category to add');
form.cat_but.focus();
return false;
}
return true;
}
//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <form name="frm1" method="post" action="favorites_cats.php" onSubmit="return validate(this);">
      <td colspan="3" valign="top">
	  <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
                <tr> 
                  <td class="titlestyle">&nbsp;Add Category to Favorites</td>
                </tr>
                <tr>
            <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="5">
          <tr> 
            <td colspan="3" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td height="25" class="innertablestyle"> <div align="center"><font class="smalltext">&nbsp;Once 
                      you added a category to your favorites then you will receive 
                      trade alerts upon posting of offers in that category.</font></div></td>
                </tr>
              </table></td>
          </tr>
          <tr valign="top"> 
            <td width="40%" align="right" class="innertablestyle"><font class="normal"><strong><font class='normal'>Choose 
              Category</font></strong></font></td>
            <td width="6">&nbsp;</td>
            <td width="60%"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#666666"> 
              <input  name = "cat_name1" type = "text" id="cat_name1"  size="35" readOnly >
              <input name = "cat1" type = "hidden" id="cat1" readonly >
              <input name=cat_but type=BUTTON id="cat_but" onClick=category('1') value="Select A Category">
              </font></td>
          </tr>
          <tr valign="top"> 
            <td align="right" class="innertablestyle"><font class="normal"><strong><font class='normal'>For 
              </font></strong></font></td>
            <td>&nbsp;</td>
            <td><font face="Arial, Helvetica, sans-serif" size="2"><strong><font color="#004566"> 
              <select name="sb_type">
			    <option value="0" selected>All </option>
                <option value="1" >Sell Offers</option>
                <option value="2">Buy Offers</option>
                <option value="3">Products Catalogs</option>
                <option value="4">Company Profiles</option>
              </select>
              </font></strong></font></td>
          </tr>
          <tr valign="top"> 
            <td align="right" class="innertablestyle">&nbsp;</td>
            <td>&nbsp;</td>
            <td><input type="submit" name="insert" value="Add"></td>
          </tr>
        </table></td>
          </tr>
        </table> 
        </td>
    </form>
  </tr>
  <tr> 
    <td height="25" colspan="3" align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr> 
    <td  valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
              <tr > 
                <td valign="top"> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" class="innertablestyle">
                    <tr> 
                      <td height="25" class="titlestyle">&nbsp;My Categories</td>
                    </tr>
                    <tr> 
                      <td valign="top"><font class='normal'>To remove a category 
                        just click the check box and click the remove button below.</font></td>
                    </tr>
                    <tr> 
                      <td valign="top"> <script language="JavaScript">
//<!--
function select_all()
{
  for (var i=0;i<document.form2.elements.length;i++)
  {
    var e =document. form2.elements[i];
    if ((e.name != 'check_all') && (e.type=='checkbox'))
    {
       e.checked = document.form2.check_all.checked;
    }
  }

}
//-->
</script> <form name="form2" method="post" action="favorites_cats.php">
                          <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
                            <tr class="subtitle"> 
                              <td width="10"> <div align="center"> 
                                  <input name="check_all" type="checkbox" id="check_all3" onClick="select_all();" value="yes">
                                </div></td>
                              <td colspan="3"><b><font class="normal">Category 
                                Name</font></b></td>
                            </tr>
                            <?
//	  $sql="Select * from sbbleads_fav_cats where sbbleads_fav_cats.mid=sbbleads_members.sb_id and sbbleads_members.sb_id =" .$_SESSION["sbbleads_userid"] ;
	
		$sql="Select * from sbbleads_fav_cats,sbbleads_categories where sbbleads_categories.sb_id=sbbleads_fav_cats.cid and mid=".$_SESSION["sbbleads_userid"]." order by sb_order_index,cid,sb_type desc";
		
	$rs0_query=mysql_query($sql);

			$cnt=0;
			while ($rs0=mysql_fetch_array($rs0_query))
			{
			$cats=mysql_fetch_array(mysql_query("select * from sbbleads_categories 
			where sb_id=".$rs0["cid"]));
			if($cnt%2==0)
			{
			?>
                            <tr> 
                              <?php
			} 
              ?>
                              <td width="10"><div align="center"> 
                                  <input type="checkbox" name="checkbox<?php echo $cnt;?>" value="<?php
			    echo $rs0["id"];?>">
                                </div></td>
                              <td><a href="<?php
							  switch($rs0["sb_type"])
							  {
							  case "sell": echo "selloffers.php?cid=".$rs0["cid"]; break;
							  case "buy": echo "buyoffers.php?cid=".$rs0["cid"]; break;
							  case "product": echo "products.php?cid=".$rs0["cid"]; break;
							  case "profile": echo "profiles.php?cid=".$rs0["cid"]; break;
							  }
							  ?>"><? echo $cats["sb_cat_name"];?></a>&nbsp; 
                                &nbsp;<font class="smalltext">[ <?php echo $rs0["sb_type"]; ?> 
                                ]</font></td>
                              <?php
				if($cnt%2<>0)
				{
              ?>
                            </tr>
                            <?
               } 
			$cnt++;
			}
			?>
                            <tr > 
                              <td colspan="2" align="left"> <div align="left"> 
                                  <input name="cnt" type="hidden" id="cnt3" value="<?php echo $cnt; ?>">
                                  <input type="submit" name="delete" value="Remove">
                                </div></td>
                            </tr>
                          </table>
                        </form></td>
                    </tr>
                  </table></td>
      </tr>
     </table></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
     </tr>
     <tr> 
       <td valign="top"> <div align="center"></div></td>
     </tr>
  </table></td>
 </tr>
</table>
<!--<br>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
  <tr > 
    <td valign="top"> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" class="innertablestyle">
        <tr> 
          <td height="25" class="titlestyle">&nbsp;Add New</td>
        </tr>
        <tr> 
          <td valign="top"> <script language="JavaScript">
function select_all()
{
  for (var i=0;i<document.form2.elements.length;i++)
  {
    var e =document. form2.elements[i];
    if ((e.name != 'check_all') && (e.type=='checkbox'))
    {
       e.checked = document.form2.check_all.checked;
    }
  }

}
</script> 
            <form action="favorites_cats.php" method="post" name="frm1" id="frm1">
              <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1">
                <tr> 
                  <td colspan="3"><?php include_once'category_function.php';?></td>
				</tr>
                <tr > 
                  <td width="92" align="left">  
                    <input type="submit" name="insert" value="Add "> </td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table>
            </form></td>
        </tr>
      </table></td>
  </tr>
</table>-->
        <?
 }
include_once("template1.php");
 
  ?> 

⌨️ 快捷键说明

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