PageRenderTime 93ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/new/PHPtemplate/formtimkiem.php

http://clover-mana.googlecode.com/
PHP | 178 lines | 146 code | 19 blank | 13 comment | 17 complexity | dd86cdfd8b5efaa0ca2327a66ead365c MD5 | raw file
  1. <div id="hightsearch">
  2. <form action="index.php?mode=search" method="post" name="timkiem">
  3. <div>
  4. <table width="400px">
  5. <tr>
  6. <td width="100px">Tęn manga </td>
  7. <td> <input type ="text" id ="txtMangaName" name="txtMangaName" width="120"/></td>
  8. </tr>
  9. <tr>
  10. <td width ="100px">Tác gi? </td>
  11. <td> <input type ="text" id="txtAuthor" name="txtAuthor" width="120"/></td>
  12. </tr>
  13. </table>
  14. </div>
  15. <div>
  16. <label>Xem nh?ng manga ?ă hoŕn t?t</label>
  17. <input name="checkboxht" type='checkbox' value="1" />
  18. </div>
  19. <?php
  20. include('PHPSource/dbconfig.php');
  21. $strSQL2 = "select * from category";
  22. $result2 = mysql_query ($strSQL2,$connection);
  23. $i = 0;
  24. while ($row = mysql_fetch_array($result2))
  25. {
  26. echo "<div>";
  27. echo "<input name='checkid[]' type='checkbox' value='$row[0]' />";
  28. echo "<label>" . $row['CategogyName'] . "</label>";
  29. echo "</div>";
  30. $i++;
  31. }
  32. ?>
  33. <div>
  34. <tr>
  35. <td>
  36. <input type="submit" name="Search" id="search" value="Search" class="serbutton"/>
  37. </td>
  38. </tr>
  39. </div>
  40. </form>
  41. </div>
  42. <?php
  43. $flag = false;
  44. session_start();
  45. $strTmp ="";
  46. if(isset($_POST["Search"]))
  47. {
  48. $flag = true;
  49. $TenMG = $_POST["txtMangaName"];
  50. //echo "TenMG";
  51. $TenTG=$_POST["txtAuthor"];
  52. //echo "TenTG";
  53. $cbHT = $_POST["checkboxht"] ;
  54. if ((isset($_POST['checkid'])) && ($_POST['checkid'] != ""))
  55. {
  56. $count = $_POST['checkid'];
  57. foreach($count as $key=>$value)
  58. {
  59. $strTmp .= " or (categogyId = '$value')";
  60. }
  61. }
  62. }
  63. $strSubSQL = "";
  64. if (!empty ($TenMG))
  65. {
  66. $strSubSQL .= " and MangaName like '%$TenMG%' ";
  67. }
  68. if (!empty ($TenTG))
  69. {
  70. $TenTG = trim($TenTG);
  71. $strSubSQL .= " and Author like '%$TenTG%' ";
  72. }
  73. if($cbHT == 1)
  74. {
  75. $strSubSQL .= "and Status = '0'";
  76. }
  77. //echo "$strSubSQL";
  78. //echo "$strTmp";
  79. if( $strTmp == "")
  80. {
  81. $strmanga = "select MID from catagorylist";
  82. }
  83. else
  84. {
  85. $strmanga = "select MID from catagorylist where categogyID = '-1'" .$strTmp;
  86. }
  87. //echo "$strSubSQL";
  88. ///////////////New///////////////////////////
  89. $strSQL = "select * from Manga where (MID in (" . $strmanga . "))" .$strSubSQL ;
  90. ////////////////////////////////////////////////////////////////////////////////////////
  91. //echo "$strSQL";
  92. $connection = mysql_connect ("localhost","root","");
  93. if (!$connection)
  94. {
  95. die('Not connected : ' .mysql_error());
  96. }
  97. $issuccess = mysql_select_db("db_manga",$connection);
  98. if(!$issuccess)
  99. {
  100. die('Can not selected database :' .mysql_error());
  101. }
  102. $result = mysql_query ($strSQL,$connection);
  103. $Count = mysql_num_rows($result);
  104. if($Count ==0)
  105. {
  106. echo "<div class = \"alert\">";
  107. echo "Không těm th?y k?t qu? nŕo!!!Xin th? l?i v?i key word khác!!";
  108. echo "</div>";
  109. }
  110. else
  111. {
  112. //echo "<div class = \"alert\">";
  113. //echo "?ă těm th?y $Count k?t qu? cho t? khóa nŕy!!!";
  114. //echo "</div>";
  115. //echo "<h2 align ='center'>?ă těm th?y $Count k?t qu? cho t? khóa nŕy!!!</h2> <br>";
  116. if($flag == true)
  117. {
  118. echo "<div class = \"alert\">";
  119. echo "?ă těm th?y $Count k?t qu? cho t? khóa nŕy!!!";
  120. echo "</div>";
  121. echo "<div id='mainContent'>";
  122. echo "<div class='maininside'>";
  123. echo "<div id='mangalist'>";
  124. echo " <table class='sample'>";
  125. echo" <tr >";
  126. echo "<th>Tęn manga</th>";
  127. echo "<th>Ngŕy thęm</th>";
  128. echo "<th>S? chap</th>";
  129. echo "</tr>";
  130. $Cout = mysql_num_rows($result);
  131. for($i=0;$i<$Cout;$i++)
  132. {
  133. $row = mysql_fetch_array($result);
  134. $tenManga = $row[1];
  135. $DateAdded = $row[2];
  136. $mid = $row[0];
  137. $DateAdded=strtotime($DateAdded);
  138. $DateAdded=date("d-m-Y",$DateAdded);
  139. $sql_1 = "select count(*) from chapter where MID = $mid";
  140. $result_1 = mysql_query($sql_1);
  141. $row_1 = mysql_fetch_array($result_1);
  142. $chap_num = $row_1[0];
  143. echo "<tr><td class='images'><p><a href='index.php?mode=chitietmanga&id=$row[0]'>";
  144. echo"$tenManga"." ";
  145. echo"<span class='new'>new</span></td></p><td width=\"150\">";
  146. //echo"<span class='hot'>hot</span></td></p> //lop truyen hot
  147. echo "$DateAdded";
  148. echo "</td>";
  149. echo "<td> $chap_num chap</td>";
  150. echo "</tr>";
  151. }
  152. mysql_close($connection);
  153. echo"</table>";
  154. echo"</div>";
  155. echo"</div>";
  156. echo"</div>";
  157. }
  158. }
  159. ?>