Forum Moderators: coopster
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Retrieve data from database
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td width="10%"><? echo $rows['id']; ?></td>
<td width="10%"><? echo $rows['username']; ?></td>
<td width="30%"><? echo $rows[password']; ?></td>
</tr>
</table>
<?php
}
// close while loop
// close connection
mysql_close();
?>
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td width="10%"><?php echo $rows['id']; ?></td>
<td width="10%"><?php echo $rows['username']; ?></td>
<td width="30%"><?php echo $rows['password']; ?></td>
</tr>
</table>
<?php
}
// close while loop