
php null değerini değiştirme
4
●108
- 06-10-2023, 22:46:51resimde görünen değerler veritabanında var fakat null olarak boş null olarak gelen değerlerin yerine "GÖRSEL YOK" yazan bir görsel eklemek istiyorum. Null değerleri yerine "<img>link</img>" gibi bunun için ne yapmam gerekiyor?

- 06-10-2023, 22:54:12<body>
<?php
//id değeri ile düzenlenecek verileri veritabanından alacak sorgu
$sorgu = $baglanti->query("SELECT * FROM emirhanemir WHERE UrunID =" . (int)$_GET['id']);
$sonuc = $sorgu->fetch_assoc(); //sorgu çalıştırılıp veriler alınıyor
?>
<div class="container">
<div class="col-md-16">
<form action="" method="post" enctype="multipart/form-data">
<table class="table">
<tr>
<td>Stok Kodu:</td>
<td><?php echo $sonuc['Urun-Kodu']; ?></td>
</tr>
<tr>
<td>Ürün Adı</td> <td><?php echo $sonuc['UrunAdi']; ?></td>
</tr>
</table>
</form>
</div>
</body>
<body>
<body>
<div class="container">
<!-- ################################################## ############ -->
<!-- Veritabanına eklenmiş verileri sıralamak için önce üst kısmı hazırlayalım. -->
<div class="col-md-10">
<table class="table">
<tr>
<th>RESİM 1</th>
<th>RESİM 2</th>
<th>RESİM 3</th>
<th>RESİM 4</th>
<th>RESİM 5</th>
<th></th>
</tr>
<tr>
<td><img width="100px" src="<?php echo $sonuc['ImageName1']; ?> " alt=""></td>
<td><img width="100px" src="<?php echo $sonuc['ImageName2']; ?>" alt=""></td>
<td><img width="100px" src="<?php echo $sonuc['ImageName3']; ?>" alt=""></td>
<td><img width="100px" src="<?php echo $sonuc['ImageName4']; ?>" alt=""></td>
<td><img width="100px" src="<?php echo $sonuc['ImageName5']; ?>" alt=""></td>
</tr>
</table>
</div>
</div>
</body> - 08-10-2023, 01:47:31Bu kısmı
<td><img width="100px" src="<?php echo $sonuc['ImageName1']; ?> " alt=""></td> <td><img width="100px" src="<?php echo $sonuc['ImageName2']; ?>" alt=""></td> <td><img width="100px" src="<?php echo $sonuc['ImageName3']; ?>" alt=""></td> <td><img width="100px" src="<?php echo $sonuc['ImageName4']; ?>" alt=""></td> <td><img width="100px" src="<?php echo $sonuc['ImageName5']; ?>" alt=""></td>
Böyle değiştirin
<?php for ($i=1; $i<=5; $i++): ?> <td><img width="100px" src="<?php echo ($sonuc['ImageName' . $i] ? $sonuc['ImageName' . $i] : 'gorselyok.png'); ?> " alt=""></td> <?php endfor; ?>
dijitalelektrik adlı üyeden alıntı: mesajı görüntüle