Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. <style>
  2. table#students {
  3.     font-size:16px;
  4.     font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  5.     border-collapse: collapse;
  6.     border-spacing: 0;
  7.     width: 100%;
  8. }
  9.  
  10. #students td, #students th {
  11.     border: 1px solid #ddd;
  12.     text-align: left;
  13.     padding: 8px;
  14. }
  15.  
  16. #students th {
  17.     padding-top: 11px;
  18.     padding-bottom: 11px;
  19.     background-color: #16a085;
  20.     color: white;
  21. }
  22. </style>
  23. <?php
  24. $username = "244623";
  25. $password = "oocohcoh";
  26. $conn = @mysqli_connect("localhost", $username, $password)
  27.     Or die("<p>Unable to connect to the database server.</p>" . "<p>Error code " . mysqli_connect_errno() . ": " . mysqli_connect_error()) . "</p>";
  28.  
  29. @mysqli_select_db($conn, "244623") Or die("<p>The database is not available. </p>");
  30.  
  31. if($_GET['delete']){   
  32.     $query = "delete from students where email='$_GET[delete]'";
  33.     $rs = mysql_query ($conn, $query);
  34.     //print_r($conn);
  35.     if($rs){
  36.         echo "Successfully deleted student with email $_GET[delete]";
  37.     } else
  38.         echo "Failure deleting student with email $_GET[delete]:" . mysqli_error($conn);
  39. }  
  40.  
  41. $sql         = "SELECT firstname, lastname, email FROM students";
  42. $QueryResult = mysqli_query($conn, $sql);
  43.  
  44. echo "<h1>Students list</h1>";
  45. echo "<table id='students' width='100%' border='0'>";
  46. echo "<tr>
  47.         <th>Firstname</th>
  48.         <th>Lastname</th>
  49.         <th>Email</th>
  50.         <th>Delete</th>
  51.     </tr>";
  52. $Row = mysqli_fetch_row($QueryResult);
  53. $c   = true;
  54. do {
  55.     echo '<tr bgcolor=' . (($c = !$c) ? '"#7f8c8d"' : '"#f2f2f2"') . ">
  56.             <td>{$Row[0]}</td>
  57.             <td>{$Row[1]}</td>
  58.             <td>{$Row[2]}</td>
  59.             <td ><a href='index.php?delete={$Row[2]}'>Delete</a></td>
  60.         </tr>";
  61.     $Row = mysqli_fetch_row($QueryResult);
  62. } while ($Row);
  63. echo "</table>";
  64. mysqli_close($conn);
  65. ?>
  66. <br><br>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement