Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php header('Content-type: text/html; charset=iso-8859-2'); ?>
  2. <html>
  3. <header>
  4. <link rel="stylesheet" type="text/css" href="mystyle.css">
  5. </header>
  6. <head>Wypożyczalnia</head>
  7. <body>
  8.  
  9.  
  10.  
  11. <?php
  12. $dbhost = 'localhost';
  13. $dbuser = '15_koziol';
  14. $dbpass = 'U6t9r6y1r1';
  15. $dbname = '15_koziol';
  16. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  17. if (!$conn ) {
  18. die('Bład połączenia z serwerem: ' . mysql_error());
  19. }
  20. mysql_select_db($dbname);
  21.  
  22.  
  23. echo "<table>";
  24. //sortowanie
  25. if(isset($_POST['sort']))
  26. {
  27. echo "Posortowane dane wg ".$_POST['sort']." :<br>";
  28. $wynik = mysql_query("SELECT * FROM samochody ORDER BY ".$_POST['sort'].";");
  29. } else {
  30. $wynik=mysql_query("SELECT * FROM samochody;",$conn);
  31. }
  32.  
  33. echo "<table border='1'>";
  34. echo "<tr>";
  35. echo "<td>Akcja</td>";
  36. for ($i=1; $i<mysql_num_fields($wynik); $i++)
  37. {
  38. $tabela=mysql_fetch_field($wynik, $i);
  39. echo "<td><form action='' method='POST'><input type ='submit' value=$tabela->name name='sort'></form></td>";
  40. }
  41. echo "</tr>";
  42.  
  43. while ($wiersz = mysql_fetch_array($wynik, MYSQL_ASSOC)) {
  44. echo "<tr>";
  45. $i=0;
  46. foreach($wiersz as $komorka)
  47. {
  48. if($i==0)echo "<td><form action='next.php' method='POST'><input type='hidden' value='$komorka' name='xyz'><input type='submit' value='wybor' name=''></form></td>";
  49. else echo "<td>".$komorka."</td>";
  50. $i++;
  51. }
  52. }
  53. echo "</tr>";
  54. echo "<br>";
  55. echo "</table>";
  56.  
  57.  
  58. ?>
  59.  
  60.  
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement