/Quản lý website bán áo đồng phục PHP/lamao/modules/bp.php
PHP | 207 lines | 207 code | 0 blank | 0 comment | 1 complexity | ecbb5104646bb92dd5ad5fb889943fdd MD5 | raw file
- <?php if (substr_count($_SERVER['PHP_SELF'],'/bp.php')>0) die ("You can't access this file directly..."); ?>
- <div class="bo">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <?php
- if (isset($_REQUEST['catID']))
- {
- $tblname='products';
- $query ='select * from '.$tblname.'_cat where id='.$_REQUEST['catID'].'';
- $doquery=mysql_query($query,$link);
- if ($doquery and mysql_num_rows($doquery)>0)
- {
- $result=mysql_fetch_array($doquery);
- $path=$result['level'];
- $name=$result['name'];
- $level=strlen(str_replace('.','',$path))/2;
- }
- $obj=$level;
- switch ($obj)
- {
- case '1':
- $itemonrow=1;
- $rows=18;
- $curpage=1;
- // Get title
- $query1 ='select '.$tblname.'.*,'.$tblname.'_cat.level as category_level';
- $query1.=' from '.$tblname.' inner join '.$tblname.'_cat';
- $query1.=' on '.$tblname.'.category='.$tblname.'_cat.id';
- $query1.=' where '.$tblname.'_cat.level like "'.$path.'%"';
- //echo $query1;
- $doquery1=mysql_query($query1,$link);
- if ($doquery1 and mysql_num_rows($doquery1)>0)
- {
- $catid='';
- $j=0;
- while($result1=mysql_fetch_array($doquery1))
- {
- $j++;
- $id=$result1['id'];
- $chain=chain($tblname,$result1['category_level'],'level',get_langID());
- $catid.=$id.',';
- }
- }
- ?>
- <tr>
- <td height="29" colspan="3" background="/images/bg_center1.gif">
- <p>
- <div style="float:left; margin-top:3px;"> <img src="/images/home_ico.gif" height="20" width="20"/></div>
- <div style="float:left; margin-top:5px;"><font class="btitle"> <?php echo $name; ?> </font></div>
- </p>
- </td>
- </tr>
- <tr><td colspan="3" height="20" align="right" style="padding-top: 6px;"><?php include ($module_dir.'navigator.php'); ?></td></tr>
- <tr><td height="29" colspan="3" align="center">
- <?php
- // Get items
- $query2 ='select * from '.$tblname.' where';
- $query2.=' id in ('.$catid.') and';
- $query2.=' lang="'.get_langID().'"';
- $query2.=' and '.$tblname.'.active=1';
- $query2.=' order by log DESC';
- $query2= str_replace(',)',')',$query2);
- //echo $query2;
- //show_content();
- if (isset($_REQUEST['curpage'],$_REQUEST['totalpage'],$_REQUEST['found']))
- {
- $found=$_REQUEST['found'];
- $totalpage=$_REQUEST['totalpage'];
- $curpage=$_REQUEST['curpage'];
- $from=($curpage-1) * $itemonrow * $rows;
- $to=$from + $itemonrow*$rows;
- $limit=' limit '.$from.','.$to;
- }
- if (isset($limit,$query2))
- $query2.=$limit;
- //exit;
- //echo $query2;
- $doquery2=mysql_query($query2,$link);
-
- if ($doquery2 and mysql_num_rows($doquery2)>1)
- {
- if (!isset($found))
- $found=mysql_num_rows($doquery2);
- if (!isset($totalpage))
- {
- if ($found<($itemonrow*$rows))
- $totalpage=1;
- else
- {
- if ($found%($itemonrow*$rows)==0)
- $totalpage=$found/($itemonrow*$rows);
- else
- $totalpage=(int)($found/($itemonrow*$rows))+1;
- }
- }
- if (isset($found) and $found!=0)
- {
- }
- $i=0;
- while ($result2=mysql_fetch_array($doquery2) and $i<=($itemonrow*$rows))
- {
- $title=$result2['title'];
- $content=stripslashes($result2['content']);
- $id=$result2['id'];
- $image=$result2['image'];
- $category=$result2['category'];
- $price=bsVndDot($result2['price']);
- //$url='?module=dp&catID='.$category.'&artID='.$id;
- $url='/chi-tiet-san-pham/'.$category.'/'.$id.'/'.removeSpecialChars(removesign($title)).'.html';
- //Show item
- ?>
- <div class="bg">
- <div class="vien">
- <div><a href="/<?php echo $image; ?>" rel="lightbox"><?php displaypic($image,'medium','center'); ?></a></div>
- <div class="title"><a href="<?php echo $url; ?>"><?php echo $title; ?></a></div>
- <div class="gia"><?php echo $price; ?> VNĐ</div>
- </div>
- </div>
- <?php
- $i++;
- if ($i==$rows*$itemonrow)
- break;
- }
- ?>
- </td></tr>
- <tr><td height="30" colspan="3" align="right" style="padding: 6 6 6 6;">
- <?php
- if (isset($totalpage))
- {
- for ($i=1; $i<=$totalpage; $i++)
- {
- //if ($i%20==1)
- //echo '</p><p class="title" style="font-weight: bold; text-align: right;">';
- echo '<input type="button" value="';
- if ($i<10)
- echo '0';
- echo $i.'"';
- if ($i!=$curpage)
- {
- echo ' class="button"';
- echo ' onClick="browse('.$i;
- echo ')"';
- echo ' onmouseover="this.className=\'button_over\'" onmouseout="this.className=\'button\'"';
- }
- else
- echo ' class="button_down"';
- echo "> \n";
- }
- }
- ?>
- <script language="Javascript">
- function browse(curpage)
- {
- document.browsesearch.curpage.value=curpage;
- //document.browsesearch.cat.value=cat;
- document.browsesearch.submit();
- }
- </script>
- <form name="browsesearch" method="get" action="">
- <input type="hidden" name="module" value="bp">
- <input type="hidden" name="found" value="<?php echo $found; ?>">
- <input type="hidden" name="totalpage" value="<?php echo $totalpage; ?>">
- <input type="hidden" name="curpage" value="">
- <?php
- if (isset($_REQUEST['catID']))
- echo "<input type=\"hidden\" name=\"catID\" value=\"".$_REQUEST['catID']."\">\n";
- ?>
- </form>
- </td></tr>
- <?php
- }
- else
- {
- if (mysql_num_rows($doquery2)==1)
- {
- $result2=mysql_fetch_array($doquery2);
- $id=$result2['id'];
- $title=$result2['title'];
- $category=$result2['category'];
- //$url='?module=dp&artID='.$id.'&catID='.$category;
- $url='/chi-tiet-san-pham/'.$category.'/'.$id.'/'.removeSpecialChars(removesign($title)).'.html';
- ?>
- <script>
- //replace
- window.location.replace("<?php echo $url; ?>")
- </script>
- <?php
- }
- else
- {
- ?>
- <script>
- alert("<?php echo $display['noarticle']; ?>")
- window.history.go(-1)
- </script>
- <?php
- }
- }
- break;
-
- default:
- break;
- }
- }
- ?>
- </td></tr>
- </table>
- </div>