Display Mysql data using Php Tutorial

Our First tutorial based on Display data from mysql table. Using PHP you can run a MySQL SELECT query to fetch the data out of the database. You have several options in fetching information from MySQL. PHP provide several functions for this. The first one is mysql_fetch_array()which fetch a result row as an associative array, a numeric array, or both.
Below codes is to using display record from table. Paste above codes in your editors.
>".mysql_error());

//count how many records found
$num=mysql_num_rows($rs);

if($num>0){ //check if more than 0 record found

echo "";
//start table             
//creating our table heading         
echo " ";             
echo "";             
echo "";             
echo "";         
echo "";                 
//retrieve our table contents         while($row=mysql_fetch_array($rs)){             //extract row             
//this will make $row['firstname'] to             
//just $firstname only             
extract($row);                         
//creating new table row per record             
echo "";                 
echo "";                 
echo "";                 
echo "";             
echo "";         }     
echo "
FirstnameLastnameUsername
{$firstname}{$lastname}{$username}
";//end table }else{ //if no records found echo "No records found."; } ?>

Our output will look like:

Now That's we have done!
Share:

No comments:

Post a Comment