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..........

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.