Thursday, 29 August 2013

How to get and display all the data of database in php

How to get and display all the data of database in php

Well i am creating a web app in which i need to display all the rows from
the database , the code and database structure is :
------------------------------------------
id | product_name | link
------------------------------------------
1 | example_1 | #
2 | example_2 | #
3 | example_3 | #
$sql = "SELECT * FROM `site_product` WHERE `product_cat` = 'home'";
while ($row = mysql_fetch_assoc($result)) {
echo "$row['product_name']; }
so however i get only one result and rest of the rows are not being in
output I think of using "forloop" but dnt have any idea to implement it ..
please help .

No comments:

Post a Comment