SQL Results into HTML Table
-
Hi i am new to this, however, i feel i am learning and getting on with it. however i have ran into a problem.
the insert php i have got working on this page but the results are not great in terms of they need formatting
https://luxor-lettings.com/our-properties/click-through/but i want to get the results into a HTML table so i have attempted it on another page – i have attempted with the following code on this page:
https://luxor-lettings.com/results-2/<html>
<head>
<title>Available Properties</title>
</head>
<body>
<table>
<thead>
<tr>
<td>Property Image</td>
<td>Property Description</td>
<td>Property Availability</td>
</tr>
</thead>
<tbody>
[insert_php]
$servername = “db567706584.db.1and1.com”;
$username = “username”;
$password = “password”;
$dbname = “db567706584”;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}
$sql = “SELECTProperty Thumbnail URL
,Property Title4HTML
,Image Tag
FROMProperties
,Available
WHEREProperty Available Flag
=Flag
ANDProperty Available Flag
= ‘2’”;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
[/insert_php]
<tr>
<td>[insert_php] echo $row[‘Property Image’][/insert_php]</td>
<td>[insert_php] echo $row[‘Property Description’][/insert_php]</td>
<td>[insert_php] echo $row[‘Property Availability’][/insert_php]</td>
</tr>
[insert_php]
}
} else {
echo “0 results”;
}
$conn->close();
[/insert_php]
</tbody>
</table>
</body>
</html>but i get get errors – any help appreciated
what should i be changing to get the results into a table? thanks
- The topic ‘SQL Results into HTML Table’ is closed to new replies.