Hi guys I have a working simplified php table as shown below.
<!DOCTYPE html>
<html>
<head>
<title>LifeSaver DB</title>
<h1> LifeSaver Database </h1>
</head>
<body>
<table>
<tr>
<th>Id</th>
<th>Location</th>
<th>Footage</th>
<th>Notes</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "Kevin", "Pass", "LifeSaverDB");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, Location, Footage, Notes FROM LifeSaver1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//for href row
$id = $row['id'];
$Footage = ['Footage'];
echo
"<tr>
<td>" . $row["id"]. "</td>
<td>" . $row["Location"] . "</td>
<td>" . $row["Notes"] . "</td>
<td> <a href='test.php'?id= . $id .'>" . $row['Footage'] . "</a> </td>
</tr>";}
//show table
echo "</table>";
} else { echo "0 results"; }
$conn->close();
?>
</table>
</body>
<style>
table, td, th {
border: 1px solid black;
margin: auto;
}
table {
border-collapse: collapse;
color: #000; <!--font colour -->
font-family: monospace;
font-size: 18px;
text-align: center;}
th {
background-color: #337AFF;
color: white;
font-weight: bold; }
tr:nth-child(odd) {background-color: #add8e6}
</style>
</html>
I wanted to add a drop down menu column, now I hacked apart this little element from a larger script, that I thought would do the job.
<html>
<TABLE>
<tr>
<td>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</td>
</tr>
</TABLE>
</html>
So I thought I could just sandwich it right in there as shown below. But it says the server can't handle the request. I think the while loop doesn't like the fact that it's just a standalone list and not a row request from the phpmyadmin, but I could be wrong. Please help
<!DOCTYPE html>
<html>
<head>
<title>LifeSaver DB</title>
<h1> LifeSaver Database </h1>
</head>
<body>
<table>
<tr>
<th>Id</th>
<th>Drop</th>
<th>Location</th>
<th>Footage</th>
<th>Notes</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "Kev", "Pass", "LifeSaverDB");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, Location, Footage, Notes FROM LifeSaver1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//for href row
$id = $row['id'];
$Footage = ['Footage'];
echo
"<tr>
<td>" . $row["id"]. "</td>
<td>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</td>
<td>" . $row["Location"] . "</td>
<td>" . $row["Notes"] . "</td>
<td> <a href='test.php'?id= . $id .'>" . $row['Footage'] . "</a> </td>
</tr>";}
//show table
echo "</table>";
} else { echo "0 results"; }
$conn->close();
?>
</table>
</body>
<style>
table, td, th {
border: 1px solid black;
margin: auto;
}
table {
border-collapse: collapse;
color: #000; <!--font colour -->
font-family: monospace;
font-size: 18px;
text-align: center;}
th {
background-color: #337AFF;
color: white;
font-weight: bold; }
tr:nth-child(odd) {background-color: #add8e6}
</style>
</html>