PHP - 从mysql查询中回显html代码和变量

时间:2016-12-09 16:38:44

标签: php mysql

我正在尝试从MYSQL打印文章列表,但我一直收到错误。

while($row  = mysql_fetch_assoc($query)){
    echo "<article class='post'>
                <h2><a style='color:#43484d' href='' " .$row['url']. ";</a></h2>
                    <ul class='meta'>
                        <li><span>level :</span> <span style='color:red'>" .$row['Level']. " </span></li>
                        <li><span>Negative votes by visitors :</span> " .$row['negativeVotes']. "</li>
                        <li><span>Positive votes by visitors :</span>" .$row['positiveVotes']. "</li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-up'></span></li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-down'></span></li>
                    </ul>
              </article>"
          }

    ?>

我收到了这个

  

解析错误:语法错误,意外&#39;}&#39;,期待&#39;,&#39;或者&#39 ;;&#39;。

我做错了什么? 非常感谢!

1 个答案:

答案 0 :(得分:0)

你错过了半结肠。

while($row  = mysql_fetch_assoc($query)){
    echo "<article class='post'>
                <h2><a style='color:#43484d' href='' " .$row['url']. ";</a></h2>
                    <ul class='meta'>
                        <li><span>level :</span> <span style='color:red'>" .$row['Level']. " </span></li>
                        <li><span>Negative votes by visitors :</span> " .$row['negativeVotes']. "</li>
                        <li><span>Positive votes by visitors :</span>" .$row['positiveVotes']. "</li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-up'></span></li>
                        <li><span  style='color:#000; cursor:pointer' class='fa fa-thumbs-o-down'></span></li>
                    </ul>
              </article>";
          }

    ?>