• 07-10-2023, 15:49:26
    #1
    merhaba iyi günler altta belirttiğim gibi bir html kodum var xml verisini tabloya cekmek istiyorum. Veriyi çekiyorum fakat while döngüsü yapamadım 1 tanesi geliyor devamı gelmiyor bu işlemi nasıl yapabilirim?

    şuan bu şekilde çalışıyor:

    ikinci üçüncü dördünü ... gibi ayarlamak istiyorum

    Saygılarımla

    <!doctype html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>Test</title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
    </head>
    <body>
    <div class="container">
        <!-- ############################################################## -->
        <!-- Veritabanına eklenmiş verileri sıralamak için önce üst kısmı hazırlayalım. -->
        <div class="col-md-30">
            <table class="table">
    
                <tr>
                    <th>No</th>
                    <th>Marka</th>
                    <th>Kategori</th>
                    <th>Görsel</th>
                    <th>Stok Kodu</th>
                    <th>Ürün Adı</th>
                    <th>Liste Fiyatı</th>
                    <th>Paket Adeti</th>
                    <th>Paket Fiyatı</th>
                    <th></th>
                </tr>
    
                <!-- Şimdi ise verileri sıralayarak çekmek için PHP kodlamamıza geçiyoruz. -->
    
    <?php
    // Loading the XML file
    $xml = simplexml_load_file("deneme.xml");
    foreach($xml->children() as $Product)
    ?>
    
                    <tr>
                        <td><?php echo "$Product->urun_id";?></td>
                        <td><?php echo "$Product->marka";?></td>
                        <td><?php echo "$Product->kategori_agaci";?></td>
                        <td><img width="50px" src="<?php echo "$Product->resim1"; ?>" alt=""></td>
                        <td><?php echo "$Product->urun_kodu";?></td>
                        <td><?php echo "$Product->urun_ismi";?></td>
                        <td><?php echo "Liste Fiyatı : ".$Product->price1." "; echo "".$Product->para." <br />";?></td>
                        <td><?php echo "$Product->price7";?></td>
                        <td><?php echo "$Product->price8";?></td>
                        <td><a href="duzenle.php?id=<?php echo $id; ?>" class="btn btn-primary">Detay</a></td>
                    </tr>
    
            </table>
        </div>
    </div>
    </body>
    </html>
  • 08-10-2023, 01:50:04
    #2
    Şunlar koda dahil edilince, döngüyü fark edeceksiniz.
    foreach($xml->children() as $Product):
    <?php endforeach; ?>

    <!doctype html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>Test</title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
    </head>
    <body>
    <div class="container">
        <!-- ############################################################## -->
        <!-- Veritabanına eklenmiş verileri sıralamak için önce üst kısmı hazırlayalım. -->
        <div class="col-md-30">
            <table class="table">
    
                <tr>
                    <th>No</th>
                    <th>Marka</th>
                    <th>Kategori</th>
                    <th>Görsel</th>
                    <th>Stok Kodu</th>
                    <th>Ürün Adı</th>
                    <th>Liste Fiyatı</th>
                    <th>Paket Adeti</th>
                    <th>Paket Fiyatı</th>
                    <th></th>
                </tr>
    
                <!-- Şimdi ise verileri sıralayarak çekmek için PHP kodlamamıza geçiyoruz. -->
    
    <?php
    // Loading the XML file
    $xml = simplexml_load_file("deneme.xml");
    foreach($xml->children() as $Product):
    ?>
    
                    <tr>
                        <td><?php echo "$Product->urun_id";?></td>
                        <td><?php echo "$Product->marka";?></td>
                        <td><?php echo "$Product->kategori_agaci";?></td>
                        <td><img width="50px" src="<?php echo "$Product->resim1"; ?>" alt=""></td>
                        <td><?php echo "$Product->urun_kodu";?></td>
                        <td><?php echo "$Product->urun_ismi";?></td>
                        <td><?php echo "Liste Fiyatı : ".$Product->price1." "; echo "".$Product->para." <br />";?></td>
                        <td><?php echo "$Product->price7";?></td>
                        <td><?php echo "$Product->price8";?></td>
                        <td><a href="duzenle.php?id=<?php echo $id; ?>" class="btn btn-primary">Detay</a></td>
                    </tr>
    <?php endforeach; ?>
            </table>
        </div>
    </div>
    </body>