0

I want to view the contents of a table in my database using while loop i.e. whenever i add database into the database and open view.php i want to see all the data of the database...so i want to use while loop so that whenever i add new data into the database the while loop runs and a new row is added int the table and it gets displayed.
I am not able to think of the logic of this..as to what to write in the while loop so that a new row gets added and data gets displayed...help me out..........

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by jogesh_p
0

after making a connection with your database :>>

$query = "select * from tbl_name ";
$result = mysql_query($query) or die('Error in Query!<br />'.mysql_error());

after this now you want to fetch all the result from database table

echo '<table>';
while($row = mysql_fetch_array($result))
{
   echo '<tr>
          <td>'.$row['id'].'</td></tr>';
}
echo '</table>';

now you can fetch all the result from the database as per your requirement.

hope it will help you

take care

Edited by Reverend Jim: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.