better dbview

This commit is contained in:
Patrick McGuire
2021-10-14 09:33:42 -04:00
parent f843e282ec
commit 7c8620ff5f
+114 -44
View File
@@ -1,45 +1,115 @@
<html> <?php
<head>
<title>'birds' database 'detections' table</title> // Username is root
</head> $user = 'birder';
<body> $password = 'databasepassword';
<?php
$dbhost = 'localhost'; // Database name is gfg
$dbuser = 'birder'; $database = 'birds';
$dbpass = 'databasepassword';
$dbname = 'birds'; // Server is localhost with
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname); // port number 3308
$servername='localhost';
if($mysqli->connect_errno ) { $mysqli = new mysqli($servername, $user, $password, $database);
printf("Connect failed: %s<br />", $mysqli->connect_error);
exit(); // Checking for connections
} if ($mysqli->connect_error) {
printf('Connected successfully.<br />'); die('Connect Error (' .
$mysqli->connect_errno . ') '.
$sql = 'SELECT * FROM detections'; $mysqli->connect_error);
}
$result = $mysqli->query($sql);
// SQL query to select data from database
if ($result->num_rows > 0) { $sql = "SELECT * FROM detections";
while($row = $result->fetch_assoc()) { $result = $mysqli->query($sql);
printf("Date: %s || Time: %s || Sci_Name: %s || Com_Name: %s || Confidence: %s || Lat: %s || Lon: %s || Cutoff: %s || Week: %s || Sens: %s || Overlap: %s <br />", $mysqli->close();
$row["Date"], ?>
$row["Time"],
$row["Sci_Name"], <!DOCTYPE html>
$row["Com_Name"], <html lang="en">
$row["Confidence"],
$row["Lat"], <head>
$row["Lon"], <meta charset="UTF-8">
$row["Cutoff"], <title>Birds Database, Detections Table</title>
$row["Week"], <!-- CSS FOR STYLING THE PAGE -->
$row["Sens"], <style>
$row["Overlap"]); table {
} margin: 0 auto;
} else { font-size: large;
printf('No record found.<br />'); border: 1px solid black;
} }
mysqli_free_result($result);
$mysqli->close(); h1 {
?> text-align: center;
</body> color: #006600;
font-size: xx-large;
font-family: 'Gill Sans', 'Gill Sans MT',
' Calibri', 'Trebuchet MS', 'sans-serif';
}
td {
background-color: #E4F5D4;
border: 1px solid black;
}
th,
td {
font-weight: bold;
border: 1px solid black;
padding: 10px;
text-align: center;
}
td {
font-weight: lighter;
}
</style>
</head>
<body>
<section>
<h1>BirdsDB Detections Table</h1>
<!-- TABLE CONSTRUCTION-->
<table>
<tr>
<th>Date</th>
<th>Time</th>
<th>Sci_Name</th>
<th>Com_Name</th>
<th>Confidence</th>
<th>Lat</th>
<th>Lon</th>
<th>Cutoff</th>
<th>Week</th>
<th>Sens</th>
<th>Overlap</th>
</tr>
<!-- PHP CODE TO FETCH DATA FROM ROWS-->
<?php // LOOP TILL END OF DATA
while($rows=$result->fetch_assoc())
{
?>
<tr>
<!--FETCHING DATA FROM EACH
ROW OF EVERY COLUMN-->
<td><?php echo $rows['Date'];?></td>
<td><?php echo $rows['Time'];?></td>
<td><?php echo $rows['Sci_Name'];?></td>
<td><?php echo $rows['Com_Name'];?></td>
<td><?php echo $rows['Confidence'];?></td>
<td><?php echo $rows['Lat'];?></td>
<td><?php echo $rows['Lon'];?></td>
<td><?php echo $rows['Cutoff'];?></td>
<td><?php echo $rows['Week'];?></td>
<td><?php echo $rows['Sens'];?></td>
<td><?php echo $rows['Overlap'];?></td>
</tr>
<?php
}
?>
</table>
</section>
</body>
</html> </html>