Hi All,
I have the following code which should be populating list items from a database. However the formatting that is being displayed is not correct. If I manually add the list items as a test they display correctly as image 1 below shows. The code I am using to display these is as follows:
<li>
<a href="index.php"><i class="fa fa-th fa-fw"></i> Company 1</a>
</li>
<li>
<a href="index.php"><i class="fa fa-th fa-fw"></i> Company 2</a>
</li>
<li>
<a href="index.php"><i class="fa fa-th fa-fw"></i> Company 3</a>
</li>
If I use the following code to get the items from the database
<?php
include("../php/connection.php");
// create and run sql query
$sql_string = "SELECT * FROM categories";
$sql_result = mysqli_query($sql_con, $sql_string);
if (mysqli_num_rows($sql_result) > 0) {
//Output data of each row
while($row = mysqli_fetch_assoc($sql_result)) {
echo "<li><a href='../pages/" .$row['display_text']. "'><i class='fa fa-th-list fa-fw></i>" . $row['display_text']. "test<span class='fa arrow'></span></a></li>";
}
} else {
echo "No Categories";
}
$sql_con->close();
?>
Can anyone please advise where I am going wrong with this.
Thanks in advanced
Luke