Webocreation

Monday, February 8, 2010

list the users in the database

<?php


if (mysql_connect("localhost","root",""))
{

mysql_select_db("php_classes");

$query="select * from profile";
$result=mysql_query($query);

if (mysql_num_rows($result)>0)
{

?>
<table width="100%" border="1" cellspacing="0" cellpadding="0">

<tr>
<td>Name</td>
<td>Address</td>
<td>Username</td>
<td>Added</td>
<td>Delete</td>
<td>Edit</td>
</tr>

<?php
while ($rows=mysql_fetch_array($result,MYSQL_ASSOC))
{
?>
<tr>
<td><?php echo "{$rows['name']}"; ?></td>
<td><?php echo "{$rows['address']}"; ?></td>
<td><?php echo "{$rows['user_name']}"; ?></td>
<td><?php echo "{$rows['added_on']}"; ?></td>
<td><a href="delete_user.php?user_id=<?php echo "{$rows['user_id']}"; ?>">Delete</a></td>
<td><a href="edit.php?user_id=<?php echo "{$rows['user_id']}"; ?>">Edit</a></td>
</tr>

<?php

}//end of while
?>
</table>
<?php

}
else
{
echo "No Records found";
}



}
else
{
echo "Could not connect to database";
}



?>

list the users in the database

No comments:

Post a Comment