SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Forbind til vores database
  3. include('db.php');
  4.  
  5.  
  6. if (isset($_POST['navn'])) {
  7.     // Slet den gamle note
  8.     $navn = trim($_POST['navn']);
  9.     $db->query("DELETE FROM radar WHERE navn LIKE '$navn'");
  10.     echo $db->error;
  11.    
  12.     // Opret nyt, hvis der er indtastet en lokation
  13.     if (strlen($_POST['lokation']) > 2) {
  14.         $navn = trim($_POST['navn']);
  15.         $lokation = trim($_POST['lokation']);
  16.         $tid = trim($_POST['tid']);
  17.         $noter = trim($_POST['noter']);
  18.        
  19.         $db->query("INSERT INTO radar (navn, lokation, tid, noter) VALUES('$navn','$lokation','$tid','$noter')");
  20.         echo $db->error;
  21.         //header('Location: radar.php');
  22.         //exit();
  23.     }
  24.    
  25.    
  26. }
  27.  
  28.  
  29.  
  30. // Start vores side.
  31. $aktiv_menu = 'radar';
  32. include('templates/side_start.php');
  33.  
  34. $resultat = $db->query("SELECT * FROM radar");
  35. echo "<table><tr><td class='tabel-label'>Navn<td class='tabel-label'>Sted<td class='tabel-label'>Længde<td class='tabel-label'>Noter</tr>";
  36. while ($radar = $resultat->fetch_array() ) {
  37.     echo "<tr>";
  38.     echo "<td class='tabel-felt'>" . $radar['navn'] . "</td>";
  39.     echo "<td class='tabel-felt'>" . $radar['lokation'] . "</td>";
  40.     echo "<td class='tabel-felt'>" . $radar['tid'] . "</td>";
  41.     echo "<td class='tabel-felt'>" . $radar['noter'] . "</td>";
  42.     echo "</tr>";
  43. }
  44.  
  45. echo "</table>";
  46. ?>
  47. <br />
  48. <br />
  49. <form action='radar.php' method='post'>
  50. <table>
  51.  
  52.     <tr>
  53.         <td class='tabel-label'>Navn:</td><td class='tabel-felt'><input type='text' name='navn' size='30'></td>
  54.     </tr>
  55.     <tr>
  56.         <td class='tabel-label'>Lokation:</td><td class='tabel-felt'><input type='text' name='lokation' size='30'></td>
  57.     </tr>
  58.     <tr>
  59.         <td class='tabel-label'>Varighed:</td><td class='tabel-felt'><input type='text' name='tid' size='30'></td>
  60.     </tr>
  61.     <tr>
  62.         <td class='tabel-label'>Noter:</td><td class='tabel-felt'><textarea name='noter' rows='5' cols="40"></textarea></td>
  63.     </tr>
  64.     <tr>
  65.         <td>&nbsp;</td><td class='tabel-felt'><input type='submit' value='gem'></td>
  66.     </tr>
  67. </table>
  68. </form>
  69.  
  70. <?php
  71. // Slut på vores side.
  72. include('templates/side_slut.php');
  73. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top