Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- table#students {
- font-size:16px;
- font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
- border-collapse: collapse;
- border-spacing: 0;
- width: 100%;
- }
- #students td, #students th {
- border: 1px solid #ddd;
- text-align: left;
- padding: 8px;
- }
- #students th {
- padding-top: 11px;
- padding-bottom: 11px;
- background-color: #16a085;
- color: white;
- }
- </style>
- <?php
- $username = "244623";
- $password = "oocohcoh";
- $conn = @mysqli_connect("localhost", $username, $password)
- Or die("<p>Unable to connect to the database server.</p>" . "<p>Error code " . mysqli_connect_errno() . ": " . mysqli_connect_error()) . "</p>";
- @mysqli_select_db($conn, "244623") Or die("<p>The database is not available. </p>");
- if($_GET['delete']){
- $query = "delete from students where email='$_GET[delete]'";
- $rs = mysql_query ($conn, $query);
- //print_r($conn);
- if($rs){
- echo "Successfully deleted student with email $_GET[delete]";
- } else
- echo "Failure deleting student with email $_GET[delete]:" . mysqli_error($conn);
- }
- $sql = "SELECT firstname, lastname, email FROM students";
- $QueryResult = mysqli_query($conn, $sql);
- echo "<h1>Students list</h1>";
- echo "<table id='students' width='100%' border='0'>";
- echo "<tr>
- <th>Firstname</th>
- <th>Lastname</th>
- <th>Email</th>
- <th>Delete</th>
- </tr>";
- $Row = mysqli_fetch_row($QueryResult);
- $c = true;
- do {
- echo '<tr bgcolor=' . (($c = !$c) ? '"#7f8c8d"' : '"#f2f2f2"') . ">
- <td>{$Row[0]}</td>
- <td>{$Row[1]}</td>
- <td>{$Row[2]}</td>
- <td ><a href='index.php?delete={$Row[2]}'>Delete</a></td>
- </tr>";
- $Row = mysqli_fetch_row($QueryResult);
- } while ($Row);
- echo "</table>";
- mysqli_close($conn);
- ?>
- <br><br>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement