如何编写echo代码

时间:2016-10-28 19:39:43

标签: database class icons

我正试图从我自己获取awsome字体图标,通过从MySQL数据库中检索,在数据库查询中,我把echo放在表格中,就像这样......

$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>

请查看其所说的代码

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

我正在尝试将图标列名放在类中,但是我在代码中遇到错误,我的问题是如何编写正确的代码来显示类中的图标!

aM

1 个答案:

答案 0 :(得分:0)

你的报价很乱......

使用反斜杠来逃避qoutes,请在此处阅读:https://stackoverflow.com/a/7999163/4195586

以下是代码中最后一行的示例:

<td>  <i class = \"fa ".$icon."\" ></i> </td>  </tr> ";