Click here to Skip to main content
16,020,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have database table called "cars"


with five columns
1. id
2. car_model
3. car_price
4. car_millage
5. seller_type

i don't know how to filter my database table to display one car model only.

What I have tried:

//my function in database.php
function fetch_referrals()
{
$sql=sprintf("select * from cars");
$rs = mysqli_query($this->link,$sql);

if(mysqli_num_rows($rs)!=0)
return $rs;
return false;
}

//my dashboard.php page




<?php


$rs=$obj->fetch_referrals();
$i=0;
if($rs)
{ while($row=mysqli_fetch_assoc($rs))
{ $i++;?>



?>
}
Car Model Car PriceCar MillageSeller Type
<?php if ($row['car_model']=="BMW") echo $row['car_model']; ?> <?php if ($row['car_price']=="BMW") echo $row['car_price']; ?><?php if ($row['car_millage']=="BMW") echo $row['car_millage']; ?><?php if ($row['seller_type']=="BMW") echo $row['seller_type']; ?>

<?php if(!$rs){?>
No data

<?php }?>
Posted
Updated 23-Nov-17 6:42am

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900