daily pastebin goal
94%
SHARE
TWEET

Untitled

a guest May 31st, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.    
  3.     //Connecting to database
  4.     $hostname = "localhost";
  5.     $database = "test";
  6.     $username = "root";
  7.     $password = "";
  8.    
  9.     $login = mysql_connect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
  10.     mysql_select_db($database);
  11.        
  12.         echo('<input type="text" name="Name"/>');
  13.         echo('<input type="text" name="Klasse"/>');
  14.         echo('<form method="post"><input type="submit" value="Einfügen" name="knopf" /></form>');
  15.         $name = mysql_real_escape_string($_POST['Name']);
  16.         $klasse = mysql_real_escape_string($_POST['Klasse']);
  17.         $query = "INSERT INTO schüler(id,schüler,klasse) VALUES (NULL,'$name','$klasse')";
  18.         if (isset( $_POST [ 'knopf' ]))
  19.         {
  20.             mysql_query($query) or die (mysql_error());
  21.         }
  22.        
  23.         //Getting the data
  24.         $sql = "SELECT id,schüler,klasse FROM schüler";
  25.         $result = mysql_query($sql) or die(mysql_error());  
  26.        
  27.         //Displays the data.
  28.         while($rad=mysql_fetch_array($result))
  29.         {      
  30.             echo  '<table width="100%">
  31.                     <tr>
  32.                     <td>
  33.                     '.$rad['id'].' - '.$rad['schüler'].' - '.$rad['klasse'].'
  34.                     </td></tr></table>';
  35.         }
  36.             if(mysql_num_rows($result) == 0)
  37.             {  
  38.                 echo '<b>No users to display!</b>';
  39.             }  
  40.        
  41. ?>
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