Arkadaşlar
Php Pdo ile veri çekiyorum ama tek bir veri çekiyor tabloda alt alta litelemiyor.
Tabloya bir adet veri ekleniyor <td><?php echo $row['resim_adi'].""; ?></td>
php kodundaki eco da ise tamamı listeleniyor sebebi nedir?
foreach( $query as $row ){
echo $row['resim_adi']."";
}
}
<?php include("../ayar.php"); ?>
<?php
$query = $db->prepare("SELECT * FROM resimler ");
$query->execute();
if ( $query->rowCount() ){
foreach( $query as $row ){
echo $row['resim_adi']."";
}
}
?>
<!-- DataTables Example -->
<div class="card mb-3">
<div class="card-header">
<i class="fas fa-table"></i>
Data Table Example</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td><?php echo $row['resim_adi'].""; ?></td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
PHP PDO Veri Çekme Listelemede Tabloma Tek Veri Geliyor
4
●302
- 30-10-2018, 15:56:26$query = $db->query("SELECT * FROM resimler")->fetchAll(PDO::FETCH_ASSOC);
// Edit
<?php $images = $db->query("SELECT * FROM resimler")->fetchAll(PDO::FETCH_ASSOC); ?> <?php if (count($images) > 0): ?> <?php foreach ($images as $i): ?> <tr> <td>Tiger Nixon</td> <td><?= $i['resim_adi'] ?></td> <td>Edinburgh</td> <td>61</td> <td>2011/04/25</td> <td>$320,800</td> </tr> <?php endforeach ?> <?php endif ?>Kaynak : https://www.erbilen.net/pdo-kullanimi/ - 30-10-2018, 16:27:19
<?php include("../ayar.php"); ?> <!-- DataTables Example --> <div class="card mb-3"> <div class="card-header"> <i class="fas fa-table"></i> Data Table Example</div> <div class="card-body"> <div class="table-responsive"> <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>Name</th> <th>Position</th> <th>Office</th> <th>Age</th> <th>Start date</th> <th>Salary</th> </tr> </thead> <tfoot> <tr> <th>Name</th> <th>Position</th> <th>Office</th> <th>Age</th> <th>Start date</th> <th>Salary</th> </tr> </tfoot> <tbody> <?php $query = $db->prepare("SELECT * FROM resimler "); $query->execute(); if ( $query->rowCount() ){ foreach( $query as $row ){ echo ' <tr> <td>Tiger Nixon</td> <td>'.$row['resim_adi'].'</td> <td>Edinburgh</td> <td>61</td> <td>2011/04/25</td> <td>$320,800</td> </tr> '; } } ?> </tbody> </table>