HTML/PHP Database Dump
<?php $con = mysqli_connect("computer", "user", "password", "database"); //This references the database. We store it as a variable only so that we don't have to keep writing it out. if(mysqli_connect_errno()) { die("Could not connect: " . mysqli_connect_errno());//Kills the connection if an error and uses mysqli_connect_errno () to print a readable message to the screen /*The error number will pass as a zero if it is successful; otherwise it will include an error number. The "." is a concatenator. */ } /*If we made it this far, it means that we successfully connected and made it to the next line. By putting echo, we are including html now!!*/ echo ' <html>
<head> <title>Ooga</title> </head> <body>
It is Tims Fault
';
$sql = "SELECT * FROM `table`;";
$result = mysqli_query($con, $sql); //This does what we have been doing in SQL: connecting to the database, and then putting in the query.
while ($row=mysqli_fetch_array($result))//This command just looks at a table row by row.
/*This while loop allows the computer to keep going back in and getting another result*/
{
echo '
'; /*This closes out the echo*/
}
echo '
Accession | Ordered By | Test | Turn Around Time | Result |
---|---|---|---|---|
' . $row['col1'] . ' | ' . $row['col2'] . ' | ' . $row['col3'] . ' | ' . $row['col4'] . ' | ' . $row[] . ' |
</body>
</html> '; ?>