Thread: info into array
View Single Post
  #2 (permalink)  
Old 07-07-09, 07:20 AM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
PHP Code:

<?php
// Make a MySQL Connection
mysql_connect("localhost""admin""****") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

// Get all the data from the "example" table
$result mysql_query("SELECT * FROM example"
or die(
mysql_error());  

echo 
"<table border='1'>";
echo 
"<tr> <th>Name</th> <th>Age</th> </tr>";
// keeps getting the next row until there are no more to get
while($row mysql_fetch_array$result )) {
    
// Print out the contents of each row into a table
    
echo "<tr><td>"
    echo 
$row['name'];
    echo 
"</td><td>"
    echo 
$row['age'];
    echo 
"</td></tr>"


echo 
"</table>";
?>

Last edited by Nico; 07-07-09 at 08:11 AM.
Reply With Quote