私は最近 Javascript の学習を始めましたが、まだこの分野の専門家ではありません。
だから、クラウドが私を助けてくれるかどうか疑問に思っていました。
MySql データベースと PHP を使用してポートフォリオ サイトを構築しています
私のデータベース テーブルには 3 つのコロンがあります: name, small_image, description
.
と を抽出するように PHP をセットアップしましname
たsmall_image
。
$name = htmlentities( $row['name'] );
$image_small = "images/" . $row['image_small'];
そして、次のようにエコーします:
$name
< img src='$image_small' with='$width' height='$height' />
私の唯一の問題は、管理ページに移動して、サイトに画像のない新しい作品を追加すると、空のスペースが表示されることです。
私がやりたいことは、不足している画像を置き換えることができる画像を持つことですか?
それを機能させる方法はありますか?またはそれを行うためのより良い、簡単な方法はありますか?
ほんとうにありがとう 。
完全なコードはここでは動作しません。
< - - - - - - - - - - - - - - - - - - フルコード - - - - - - - - - - - - - - - >
// Loop through all of the records returned from the query
while( $row = mysql_fetch_array( $results ) ) {
// collect data from each field
$id = $row['id'];
$name = htmlentities( $row['name'] );
$desc_short = htmlentities( $row['desc_short'] );
if(isset( $row['image_small'])){
$image_small = "images/jewelry/small/" . $row['image_small'];
}
else{
$image_small = "images/blank.jpg";
}
echo "
<li class='column_$x $last_row_class'>
<a href='details.php?id=$id'>
<img src='$image_small' with='$width' height='$height' />
</a>
<p class='product_name'><a href='details.php?id=$id'>$name</a></p>
<p class='product_desc'>$desc_short</p>
$rating_div
</li>";