Drezard Posted September 17, 2006 Share Posted September 17, 2006 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 Link to comment https://forums.phpfreaks.com/topic/21050-control-panel/ Share on other sites More sharing options...
Daniel0 Posted September 17, 2006 Share Posted September 17, 2006 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> </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] Link to comment https://forums.phpfreaks.com/topic/21050-control-panel/#findComment-93439 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.