Advertisement
Guest User

Untitled

a guest
Apr 19th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2. include_once ('zdroje/init.php');
  3.  
  4.  
  5.  
  6. ?>
  7.  
  8. <html>
  9. <head>
  10.     <meta charset = 'utf-8'>
  11.     <style>
  12.     label {display:block;}
  13.     </style>
  14.     <title> Pridani Clanku</title>
  15. </head>
  16. <body>
  17.     <h1> Pridani Clanku </h1>
  18.  
  19.     <form action = "" method="post">
  20.         <div>
  21.             <label for = "Titulek"> Titulek </label>
  22.             <input type = "text" name="nazev">
  23.         </div>
  24.         <div>
  25.             <label for = "Clanek"> Clanek </label>
  26.             <textarea name= "text" rows="15" cols= "50"></textarea>
  27.         </div>
  28.         <div>
  29.             <label for = "Kategorie"> Kategorie </label>
  30.             <select name = "kategorie">
  31. <?php
  32.         include_once('func/blog.php');
  33.         $servername = "localhost";
  34. $username = "root";
  35. $password = "";
  36. $dbname = "blog";
  37.  
  38. // Create connection
  39. $conn = new mysqli($servername, $username, $password, $dbname);
  40. // Check connection
  41. if ($conn->connect_error) {
  42.     die("Connection failed: " . $conn->connect_error);
  43. }
  44.  
  45. $sql = "SELECT id,nazev FROM kategorie";
  46. $result = $conn->query($sql);
  47. $row = $result->fetch_assoc();
  48.        
  49.  
  50. ?>
  51. <?php      
  52. while($row = $result->fetch_assoc()) {
  53.                 ?>
  54.                     <option value = "<?php echo " Name: " . $row["id"]. ";"?>">
  55.                 <?php
  56.                     echo " Name: " . $row["nazev"]. "";
  57.                                     }  
  58.        
  59.                 ?> 
  60.  
  61.            
  62.  
  63.  
  64.  
  65.            
  66.             </option>/n
  67.             </select>
  68.         </div>
  69.         <div>
  70.             <input type="submit" value="Pridej kategorii">
  71.  
  72.  
  73.  
  74.         </div>
  75.  
  76.     </form>
  77.  
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement