PageRenderTime 44ms CodeModel.GetById 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Quản lý website quảng cáo PHP/module/search.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 279 lines | 86 code | 193 blank | 0 comment | 11 complexity | 8e856521f290773060744058d8f2c40a MD5 | raw file
  1. <?
  2. $keyword = killInjection($_REQUEST['keyword']);
  3. ?>
  4. <?
  5. $row =10;
  6. $col =2;
  7. $cat =0;
  8. $p=0;
  9. if ($_REQUEST['p']!='') $p=$_REQUEST['p'];
  10. $sql = "select * from tbl_product where name like '%".$keyword."%' order by sort,date_added desc limit ".$row*$col*$p.",".$row*$col;
  11. $result = @mysql_query($sql,$conn);
  12. $total = countRecord("tbl_product","name like '%".$keyword."%'");
  13. if($total==0){
  14. ?>
  15. <table align="center" cellSpacing="0" cellPadding="0" width="100%" border="0">
  16. <tr>
  17. <td align="center">
  18. <font color="#FF0000"><b><?=$_lang=="vn"?'Không tìm thấy sản phẩm xin hãy chọn từ khóa khác !':''?></b></font>
  19. </td>
  20. </tr>
  21. <tr><td height="20"></td></tr>
  22. </table>
  23. <?
  24. }else{
  25. ?>
  26. <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
  27. <script src="script/prototype.js" type="text/javascript"></script>
  28. <script src="script/scriptaculous.js?load=effects" type="text/javascript"></script>
  29. <script src="script/lightbox.js" type="text/javascript"></script>
  30. <table align="center" cellSpacing="0" cellPadding="0" width="100%" border="0">
  31. <?
  32. for($i=0; $i<$row; $i++){
  33. ?>
  34. <tr>
  35. <?
  36. for($j=0; $j<$col&&$products=mysql_fetch_assoc($result); $j++){
  37. $pro = getRecord("tbl_product","id=".$products['id'])?>
  38. <td class="margin_image_center" colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="10" class="line_bottom_center">
  39. <tr>
  40. <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  41. <tr>
  42. <td align="center"><a href="<?=$pro["image_large"]?>" rel="lightbox[roadtrip]"><img src="<?=$pro["image"]?>" alt="" width="180" height="100" border="0" class="border_image" /></a></td>
  43. </tr>
  44. <tr>
  45. <td align="center"><?=$pro["name"]?> </td>
  46. </tr>
  47. </table></td>
  48. </tr>
  49. </table></td>
  50. <?
  51. }
  52. while($j<$col){
  53. echo "";
  54. $j=$j+1;
  55. }
  56. ?>
  57. </tr>
  58. <? }?>
  59. </table>
  60. <table align="center" cellSpacing=0 cellPadding=0 width="98%" border=0>
  61. <?
  62. $newsPage = $_lang=="vn" ? "Sản phẩm" : "Products";
  63. $pagePage = $_lang=="vn" ? "Trang" : "Page";
  64. $titleFirst = $_lang=="vn" ? "Đầu Tiên" : "First";
  65. $titlePrevious = $_lang=="vn" ? "Về trước" : "Previous";
  66. $titleNext = $_lang=="vn" ? "Tiếp theo" : "Next";
  67. $titleLast = $_lang=="vn" ? "Cuối cùng" : "Last";
  68. $pages = countPages($total,$row*$col);
  69. echo '<tr><td colspan="2" align="center"></td></tr>';
  70. echo '<tr><td class="td1" align="left"></td>';
  71. echo '<td class="td1" align="right">';
  72. $param="";
  73. if ($p>1) echo '<a class="link5" title="'.$titleFirst.'" href="./?frame='.$_REQUEST['frame'].'&cat='.$_REQUEST['cat'].'&'.$param.'&p=0">[&lt;&lt;]</a> ';
  74. if ($p>0) echo '<a class="link5" title="'.$titlePrevious.'" href="./?frame='.$_REQUEST['frame'].'&cat='.$_REQUEST['cat'].'&'.$param.'&p='.($p-1).'">[&lt;]</a> ';
  75. $from=($p-10>0?$p-10:0);
  76. $to=($p+10<$pages?$p+10:$pages);
  77. for ($i=$from;$i<$to;$i++){
  78. if ($i!=$p) echo '<a class="link5" href="./?frame='.$_REQUEST['frame'].'&cat='.$_REQUEST['cat'].'&'.$param.'&p='.$i.'">'.($i+1).' </a>';
  79. else echo '<b>'.($i+1).'</b> ';
  80. }
  81. if ($p<$i-1) echo '<a class="link5" title="'.$titleNext.'" href="./?frame='.$_REQUEST['frame'].'&cat='.$_REQUEST['cat'].'&'.$param.'&p='.($p+1).'">[&gt;]</a> ';
  82. if ($p<$pages-1) echo '<a class="link5" title="'.$titleLast.'" href="./?frame='.$_REQUEST['frame'].'&cat='.$_REQUEST['cat'].'&'.$param.'&p='.($pages-1).'">[&gt;&gt;]</a>';
  83. echo '</td></tr>';
  84. ?>
  85. </table><br />
  86. <? }?>