Advertisement
Guest User

Untitled

a guest
Oct 19th, 2012
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.75 KB | None | 0 0
  1. <style>
  2. br {margin-bottom:-10px;}
  3. </style>
  4.  
  5. <form action="cerca2.php" method="post">
  6. <b>Nome</b>&nbsp;<input type="text" name="Nome">&nbsp;&nbsp;
  7. <b>Numero&nbsp;</b><input type="text" name="Numero">&nbsp;&nbsp;
  8. <b>city&nbsp;</b><input type="text" name="city">&nbsp;&nbsp;
  9. <input type="Submit">
  10. </form>
  11.  
  12. <style>
  13. tr:nth-of-type(odd) { background-color: AZURE; }
  14. tr:nth-of-type(even) { background-color: CYAN; }
  15. </style>
  16. <style>
  17. tr:hover{background-color:DEEPSKYBLUE;}
  18. </style>
  19.  
  20. <?php
  21.  
  22. echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";  
  23. echo "<tr style='font-weight: bold;'>";  
  24. echo "<th width='auto' bgcolor=”#7FFFD4″>&nbsp;<i>ID<i/></th>";  
  25. echo "<th width='auto' >&nbsp;<i>Nome<i/></th>";
  26. echo "<th width='auto' ></th>";
  27. echo "<th ></th>";
  28. echo "</tr>";
  29.  
  30. define('DB_NAME', 'forms1');
  31. define('DB_USER', 'root');
  32. define('DB_PASSWORD', '');
  33. define('DB_HOST', 'localhost');
  34.  
  35. $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
  36. if (!$link) {
  37.     die('Could not connect: ' . mysql_error());
  38. }
  39.  
  40. $db_selected = mysql_select_db(DB_NAME, $link);
  41.  
  42. if (!$db_selected) {
  43.     die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
  44. }
  45.  
  46. $Nome = str_replace(' ', '%', $_POST['Nome']);
  47. $Numero = str_replace(' ', '%', $_POST['Numero']);
  48. $city = str_replace(' ', '%', $_POST['city']);
  49.  
  50. $arNome = str_split($Nome);
  51. $arNumero = str_split($Numero);
  52. $arcity = str_split($city);
  53.  
  54. $Nome='';
  55. foreach ($arNome as $value)
  56. {
  57.    if ($value=='%') continue;
  58.    $Nome.=$value.'%';
  59.  
  60. }
  61.  
  62. $Numero='';
  63. foreach ($arNumero as $value)
  64. {
  65.    if ($value=='%') continue;
  66.    $Numero.=$value.'%';
  67.  
  68. }
  69.  
  70. $city='';
  71. foreach ($arcity as $value)
  72. {
  73.    if ($value=='%') continue;
  74.    $city.=$value.'%';
  75.  
  76. }
  77.  
  78. $sql = mysql_query("SELECT * FROM demo WHERE Autore LIKE '%$Nome%' AND Titolo LIKE '%$Numero%' AND cit LIKE '%$city%' ORDER BY Autore") or die(mysql_error());
  79.  
  80.  
  81. $i = 0; while($row=mysql_fetch_array($sql)){
  82.         $i++;
  83.         echo "<tr>";
  84.         echo "<td width='auto' bgcolor=”#FF0000 &#8243;>" . "&nbsp;". "<b>"  . $i . "&nbsp;". "<b/>". "</td>";
  85.         echo "<td width='auto'>" . "&nbsp;" . $row[1] . "&nbsp;" . "</td>";
  86.         echo "<td width='auto'>". "</td>";
  87.         echo "<td width='auto'>" . "&nbsp;". "<i>" . $row[2] . "<i/>". "&nbsp;" . "</td>";    
  88.         echo "<td width='auto'>" . "&nbsp;". "<i>" . $row[3] . "<i/>". "&nbsp;" . "</td>";
  89.         echo "</tr>";
  90. }
  91. mysql_close();
  92. ?>
  93. </table>
  94.  
  95. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  96. <script type="text/javascript" src="http://tablesorter.com/__jquery.tablesorter.min.js"></script>
  97. <script type="text/javascript">
  98.     $(document).ready(function(){ $("table").tablesorter(); });
  99. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement