Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following Bootstrap code
HTML
<li class="list-group-item">Pot na Roblek <span class="badge">2017-08-16</span> </li>

I works fine when trying to display it as is, but when i try to add it to a php script like this :
PHP
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
    echo '<li class=\"list-group-item\">'.$row["naslov"].'<span class=\"badge\">'.$row["datum"] .'</span></li>';
    }
} else {
    echo "0 rezultatov";
}

The code wont work and wont display the Bootstrap style and will instead display only a normal "list item"

What I have tried:

I have no idea what to try, but this other code works with Bootstrap:
PHP
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
            echo '<tr>';
            echo '<td class=\"success\">'.$row["datum"].'</td>';
            echo '<td class=\"success\">';
            echo '<a href="'.$row['link'].'">'.$row["naslov"].'</a>';
            echo '</td>';
            echo '</tr>';
    }
} else {
    echo "0 rezultatov";
}
Posted
Updated 24-Mar-17 14:44pm
v2

1 solution

Reddit solution Thanks to mattindustrie for this.
You are echoing out <li class=\"list-group-item\">. Take out the backslashes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900