List of users from MYSQL to page
Posted: Sat Jun 16, 2012 9:08 am
Hello everyone,
im having problem with this piece of code. I want it to create list of users registered on my message-system. Order them by username. But im not really sure that im filling the table corectly (actually what it does is create infinite number of rows)
im having problem with this piece of code. I want it to create list of users registered on my message-system. Order them by username. But im not really sure that im filling the table corectly (actually what it does is create infinite number of rows)
<?php require_once('inc/commons.php'); $_SESSION['last_page'] = 'search.php'; require_once('inc/top.php'); $message_header_title = 'Seznam uzivatelu'; $method = 'p'; $query_get_users = 'SELECT * FROM `user` ORDER BY `username` ASC LIMIT 0 , 30'; $result_get_users = mysql_query($query_get_users); $user_count = mysql_num_rows($result_get_users); ?> <div class="content"> <?php require_once('inc/message-header.php'); ?> <div class="content-body"><?php if ($user_count > 0) { ?><table class="table-grid1"> <thead> <tr> <th style="width:20%;">Jmeno</th> <th style="width:20%;">Prijmeni</th> <th style="width:20%;">Uzivatelske jmeno</th> <th>Akce</th> </tr> </thead> <tbody><?php while ($row_get_user = mysql_fetch_assoc($result_get_users)) { $query_get_users = 'SELECT * FROM `user` ORDER BY `username` ASC LIMIT 0 , 30 '; $result_get_users = mysql_query($query_get_users); $username_encrypted = encrypt($row_get_user['username']); $first_name = ''; $last_name = ''; $username = ''; ?><tr> </tr> <td><?php echo $first_name; ?></td> <td><?php echo $last_name; ?></td> <td><?php echo $username; ?></td> <td><a href="vytvor.php?r=<?php echo encrypt($row_get_users['username']); ?>&m=<?php echo $username_encrypted; ?>" title="Napsat uzivateli zpravu">Napsat zpravu</a> <?php } ?></tbody> </table><?php }else { ?><p>Nepodarilo se zobrazit seznam uzivatelu</p><?php } ?></div> </div> <?php require_once('inc/bot.php'); ?>