while loop and mysql_fetch_array() function : mysql_fetch_array « MySQL Database « PHP






while loop and mysql_fetch_array() function

 
<html>

 <head>
  <title>Get data</title>
 </head>

 <body>

 <?php

 $conn = @mysql_connect( "localhost", "userName", "password" ) or die( "Err:Conn" );

 $rs = @mysql_select_db( "my_database", $conn )  or die( "Err:Db" );

 $sql = "select id,first_name from my_table order by first_name";

 $rs = mysql_query( $sql, $conn );

 while( $row = mysql_fetch_array( $rs ) )
 {
   echo( "ID: " . $row["id"] );
   echo( " - FIRST NAME: " . $row["first_name"] . "<br>" );
 }

 ?>

 </body>

</html>
  
  








Related examples in the same category

1.An Example of Using the Old MySQL Extension
2.Get data from database
3.mysql_fetch_array-2.php
4.mysql_fetch_array.php
5.Using timestamp with mysql
6.Retrieving and Displaying Results