Get data from database : mysql_fetch_array « MySQL Database « PHP






Get data from database

 
<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";

$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.while loop and mysql_fetch_array() function
3.mysql_fetch_array-2.php
4.mysql_fetch_array.php
5.Using timestamp with mysql
6.Retrieving and Displaying Results