-2

I'm trying to get awsome font icon from myself, by retrieve from MySQL database, in the database query, I put echo with table, like this...

$sql = "SELECT * FROM boxes where categories = 'box' ";
            $result = $conn->query($sql);
            if ($result->num_rows > 0) {
                while ($row = $result->fetch_assoc()) {
                    if ($row['status'] == 1)
                        $visible = "visible";
                    else
                        $visible = "hidden";

                    if ($row['side'] == 1)
                        $side = "right";
                    else if ($row['side'] == 2)
                        $side = "left";
                    else $side = "not set yet";

                    echo " <tr> 
                  <td>" . $row['id_boxe'] . "</td>
                  <td>" . $row['title_boxe'] . "</td>
                  <td>" . $visible . "</td>
                  <td>" . $visible . "</td>
                  <td>" . $side . "</td>
                  <td> " '<i class = "fa '.$row['icon'].' " ></i>'"  </td>
                  <td><form method='post'><input type='hidden' name='id' value='" . $row['id_boxe'] . "'/>
                  <input type='submit' name='update' value='Update'/><input type='submit' name='delete' value='Delete'/></form></td>
                 </tr> ";
                }
            }
            ?>
        </tbody>

please see the code where it said

<td> " '<i class = "fa '.$row['icon'].' " ></i>'"  </td>

I'm trying to put icon column name inside of class but I'm getting the error in the code, my question is that how can I write correct code to show the icon inside of class!

aM

1 Answers1

0

You have a mess with the quotes...

Use backslashes to escape qoutes, read here: https://stackoverflow.com/a/7999163/4195586

Here is working example of the last line in your code:

<td>  <i class = \"fa ".$icon."\" ></i> </td>  </tr> ";
Community
  • 1
  • 1
Zergius2
  • 124
  • 1
  • 5