Expand|Select|Wrap|Line Numbers
- <?php
- function connect(){
- // Make a MySQL Connection
- $link = mysqli_connect("localhost", "root", "", "school") or die(mysqli_error());
- return $link;
- }
- if ($_GET)
- {
- if(isset($_GET["id"])) $id = $_GET["id"];
- }
- // select query
- $query = "SELECT * FROM graden" ;
- if (isset($id)) { $query.= " WHERE id = $id "; }
- $result = mysqli_query(connect(),$query);
- // table making
- $table = "<table border='1'>";
- $table .= "<tr>
- <th> ID </th>
- <th>Graden Celcius</th>
- <th>Aanduiding</th>
- <th>Image</th>
- </tr>";
- // keeps getting the next row until there are no more to get
- while($row = mysqli_fetch_assoc( $result )) {
- // Print out the contents of each row into a table
- foreach ($row as $key => $value) {
- if ($key == "Image") {
- $table .="<td><img src='$value' /></td>";
- } elseif ($key == "temp") {
- $table .="<td><a href='array.php?id=$value'>$value</a></td>";
- } else {
- $table .="<td>$value</td>";
- }
- }
- $table .= "</tr>";
- }
- $table .="</table>";
- echo $table;
- ?>