0

データベースに保存されている値に基づいて、ページに1から5までの星を表示したいと思います。mySQLデータベースのデータをHTMLタグでエコーするPHPコードを書き込もうとしています。コードが正しい間違っているかわかりません。私はそれをwhileループで実行し、多くのHTMLタグでデータを呼び出しています。コンピューターの画像を1stars.png、2stars.png、3stars.png、4stars.png、5stars.pngのフォルダー画像に保存しました。以下は私のコードです。

<?php
    $query = mysql_query("select * from printers where printers_id='1';");
    while ($row = mysql_fetch_array($query)) 
    {
?>
        <table width="281" border="0" style="margin-left:40px; margin-top:10px;" cellspacing="20">
        <tr>
            <td class="table_text_left"><figure>Value for money:&nbsp;&nbsp;&nbsp;&nbsp;<img src=images/"<?php echo $row['Value_For_Money'];?>".stars.png alt="5 stars" /></figure></td>
        </tr>
        </table>
<?php
}
?>
4

2 に答える 2

1

それはすべて引用符についてです。変化する

<img src=images/"<?php echo $row['Value_For_Money']; ?>".stars.png alt="5 stars" />

<img src="images/<?php echo $row['Value_For_Money']; ?>.stars.png" alt="5 stars" />
于 2013-03-27T10:02:37.140 に答える
0

私はコランバの答えを編集しました、そしてそれは今私にとってうまくいきます。コランバありがとうございます。

から

img src="images/<?php echo $row['Value_For_Money']; ?>.stars.png" alt="5 stars" />

<img src="images/<?php echo $row['Value_For_Money']; ?>stars.png" alt="5 stars" />
于 2013-03-27T10:06:53.077 に答える