terry
terry

Reputation: 43

displaying different product types

i've got featured products

$sql = "SELECT * FROM credit_card_offers WHERE featured = 1";
$featured = $db->query($sql);

then a while loop

<?php while($product = mysqli_fetch_assoc($featured)) : ?>
<?php endwhile; ?>

to display the featured products. how would i be able to show popular products ect.. on the same page when show popular products is selected?

i can do it on a diffrent .php page but im looking to do it on the same page if possible?

Upvotes: 0

Views: 41

Answers (2)

kkica
kkica

Reputation: 4104

yes, you can do that.

 <form action="file.php" method="post">
 <input type="radio" name="choice" value="popular">Popular<input type="radio" 
 name="choice" value="featured">Featured
 <input type="submit" value="Submit">
 </form>

in the php code change featured with $_POST["choice"]

Upvotes: 1

Corentin PRUNE
Corentin PRUNE

Reputation: 388

Hello have you tried fetching all your table then loop twice on the result, displaying only featured on the first loop

Upvotes: 0

Related Questions