Jump to content

Archived

This topic is now archived and is closed to further replies.

Drezard

Control Panel

Recommended Posts

Hello, how would i display everything in a table in a database but then add a html button to the side of every record. If you click the button next to the record (username = Daniel) then it would goto ww.site.com/change.php?var=Daniel but what would be the code for all of that?

Thanks, Daniel

Share this post


Link to post
Share on other sites
Something like this should do it: [code]<?php
$conn = mysql_connect("localhost", "username", "password");
mysql_select_db("some_database", $conn);

$q = mysql_query("SELECT * FROM users");
if(mysql_num_rows($q) <= 0)
{
echo "No users";
}
else {
echo <<<EOF
<table>
<tr>
<th>Username:</th>
<th>Email:</th>
<th>Website:</th>
<th>&nbsp;</th>
</tr>

EOF;
while($u = mysql_fetch_assoc($q))
{
echo <<<EOF
<tr>
<td>{$u['username']}</td>
<td><a href="mailto:{$u['email']}">{$u['email']}</a></td>
<td><a href="{$u['website']}">{$u['website']}</a></td>
<td><button type="button" onclick="location.href='http://www.example.com/change.php?var={$u['username']}'">Some button</button></td>
</tr>

EOF;
}
echo "</table>\n";
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.