PHP İsime göre veri çekme
3
●107
- 23-10-2020, 20:04:33Merhaba arkadaşlar mesela veritabanında özellik diye bir bölüm var burada kırmızı, mavi, sarı yazıyor sadece sarı yazanları listelemek istiyorum bunu nasıl yapabilirim.
- 23-10-2020, 20:06:38
$query=$db->prepare("SELECT * FROM tabloadi where ozellik=:ozellik"); $query->execute(array('ozellik' => 'sari')); $row=$query->fetch(PDO::FETCH_ASSOC); - 23-10-2020, 20:08:05Sql yapısını atar mısınız hocam? Auto increment şeklindeyse eğer bu yazdığım kod işinizi görür. id sadece 0 şeklinde bir yapıya sahipse ona göre kod yazalım.
- 23-10-2020, 20:54:49
<?php $querypacketList = $db->query("SELECT distinct(`packet`.`packet_id`),packet_name,packet_images,packet_f1,packet_f2,packet_f3,packet_f4,packet_price FROM packet INNER JOIN product ON product.packet_id = packet.packet_id WHERE packet_status = 1"); if($querypacketList->rowCount() > 0){ foreach ($querypacketList as $packetPrint) { ?> <a href="satinal.php?paketid=<?= $packetPrint['packet_id']?>" class="game"> <div class="game-pic"> <img src="<?=$packetPrint['packet_images']?>" alt="<?=$packetPrint['packet_name']?>"> </div> <div class="game-title text-center"><?=$packetPrint['packet_name']?></div> <div class="text-center"> <span class="random-chance"><?=$packetPrint['packet_f2']?><br /></span> <span class="random-chance">Anında Teslimat<br /></span> <span class="random-chance">Güvenilir Adres<br /></span> <span class="random-chance"><br /></span> </div> <div class="g-price"> <span class="game-price"><?=$packetPrint['packet_price']?> TL</span> </div> <span class="game-cost">SATIN AL</span> </a> <?php } }else{ echo "<div style='padding:10px 15px; background:#F38989; line-height:20px; border-radius:5px; color:white;'> <div style='display:flex;'> <img style='height:20px; line-height:20px;' src='https://img.icons8.com/doodle/48/000000/error.png'/> <b style='height:20px; line-height:20px; padding-left:10px;'>Listelenecek ürün bulanamadı!</b> </div> </div>"; } ?>Şuan ki hali bu şekilde özellik dediğim packet_f2 ancak bir türlü listeleyemedim her seferinde veri gelmiyor
aşağıdaki değişikliği yaparak çözdüm
$querypacketList = $db->query("SELECT distinct(`packet`.`packet_id`),packet_name,packet_images,packet_f1,packet_f2,packet_f3,packet_f4,packet_price FROM packet INNER JOIN product ON product.packet_id = packet.packet_id WHERE packet_status = 1 AND packet_f2 = 'Sarı'");