-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

  • It would probably help if you did show the data you are selecting. – Filburt Oct 28 '16 at 19:43
  • the data i'm selling see code $sql = "SELECT * FROM boxes where categories = 'box' "; $result = $conn->query($sql); if ($result->num_rows > 0) { – user1953826 Oct 28 '16 at 19:48
  • Please -->>[edit]<<-- your post to add details - code doesn't look so good in the comments. Also you still did not show the *data*. What will be the *value* of `$icon`? – Filburt Oct 28 '16 at 19:50
  • What's the error that your getting? If you post that along with a bit more of the surrounding code we should be able to help. The echo logic you wrote doesn't appear to be the issue. – robbymarston Oct 28 '16 at 20:00
  • I just put complete code please see how can I solve that by put column name inside of class style name. – user1953826 Oct 28 '16 at 20:02

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