G'day Webguy,
I recently built a page to 'edit' members of my DB. My code queries my DB and inserts the results into a form for editing - then re-inserting into (updating) my DB.
I'm having trouble with the updating the DB part, but for now my 'query and display' code works. Perhaps this will help you.
$check = mysql_query("SELECT * FROM users")
or die(mysql_error());
echo "<p align='center'> </p>";
echo "<p align='center'> </p>";
echo "<table border='1' align='center'>";
echo "<tr><th width='90' align='center'>Username</th>";
echo "<th width='120' align='center'>Name</th>";
echo "<th width='70' align='center'>Status</th></tr>";
while($users = mysql_fetch_array( $check )){
$username = $users['username'];
echo "<tr><td align='center'>";
echo "<a href='$username'>$username</a>";
echo "</td><td>";
echo $users['name_f'] . " " . $users['name_l'];
echo "</td><td>";
echo $users['status'];
echo "</td><td width='50' align='center'>";
echo "<a href='/edit_users.php?name=$username';>Edit</a>";
echo "</td></tr>";
}
echo "</table>";
You'll notice I have seperated the username from the results and given that a variable of it's own. This is something I found I had to do to be able to use a variable in a href link. This helps me use that name in a $_GET address line query. When I click on a user in the list some more code injects the record for that user into a form for editing.
That bit works also, so far. Just need to put it back in my DB now :p I'm working on that :s
Hope this helps.
Cheers mate.
P.