Control Panel

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Drezard2
Forum Newbie
Posts: 4
Joined: Sun Sep 17, 2006 1:35 am

Control Panel

Post by Drezard2 »

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
Omsis
Forum Newbie
Posts: 5
Joined: Sat Sep 16, 2006 1:39 pm

Post by Omsis »

this should work:

Code: Select all

<?php
$query = "SELECT * FROM users;";
$result = mysql_query($query) or die ('ERR nr1');
?>
<table border="1">
<?php
while ($row = mysql_fetch_assoc($result))
{
    ?>
    <tr>
    
    <td>
    <?php echo $row['user_id']; ?>
    </td>
    
    <td>
    <?php echo $row['col_name2']; ?>
    </td>
    
    <td>
    <?php echo $row['col_name3']; ?>
    </td>
    
    <td>
    <a href="www.site.com/change.php?var=<?php echo $row['user_id']; ?>">EDIT LINK</a>
    </td>
    
    </tr>
    <?php
}
?>
</table>

good luck! ;)
Post Reply