• 06-10-2023, 22:46:51
    #1
    resimde 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:48:28
    #2
    <?php 
    if(is_null($gorsel)) {
    echo '<img src="gorselyok.png">';
    } else {
    echo '<img src="'. $gorsel .'">';
    }
  • 06-10-2023, 22:54:12
    #3
    <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>
  • 07-10-2023, 17:13:08
    #4
    Merhaba, kodlarınızı PHP tagları arasına yazar mısınız, bu şekilde okunması zor.
  • 08-10-2023, 01:47:31
    #5
    Bu 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
    <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>