Important security update, please update to Osclass 3.7.4
At Osclass we have changed our Privacy Policy and Terms of Use in order to adapt them to the new General Data Protection Regulation (GDPR). We want you to know what user data we store, what we need them for, and who we share them with in each specific case. Furthermore, we are making it even easier for you to exercise your right to manage your own data.
Our goal is that you enjoy the best possible experience with our website. As the GDPR comes into force, legislation requires us that you grant us permission—both to us and our partners—to store cookies in your browser. Remember you can find more information about what we do with your data by clicking here.
I accept Osclass SL’s Terms of Use and Cookies Policy and grant them permission to manage my data.
<?php $users = User::newInstance()->listAll();$users = array_reverse($users);foreach($users as $user) { echo '<strong>Username</strong>: ' . '<a href="user/profile/'. $user['pk_i_id'] . '">' . $user['s_name'] . '</a>' . '<br /> ';} ?>
<?php$dao = new DAO(); // Osclass data access object.$query = $dao->dao->query(sprintf('SELECT * FROM %st_user ORDER BY dt_reg_date DESC LIMIT 10', DB_TABLE_PREFIX)); // Perform query.if(count($query)) { // If there is data that matches query $users = $query->result(); // Save it in $users variable.} else { // Else $users = null; // save null to $users variable.}foreach($users as $user) { // Loop through users. echo '<strong>Username</strong>: ' . '<a href="user/profile/'. $user['pk_i_id'] . '">' . $user['s_name'] . '</a>' . '<br /> ';}?>
Hello!Welcome to Osclass forums! Try this code:Code: [Select]<?php$dao = new DAO(); // Osclass data access object.$query = $dao->dao->query(sprintf('SELECT * FROM %st_user ORDER BY dt_reg_date DESC LIMIT 10', DB_TABLE_PREFIX)); // Perform query.if(count($query)) { // If there is data that matches query $users = $query->result(); // Save it in $users variable.} else { // Else $users = null; // save null to $users variable.}foreach($users as $user) { // Loop through users. echo '<strong>Username</strong>: ' . '<a href="user/profile/'. $user['pk_i_id'] . '">' . $user['s_name'] . '</a>' . '<br /> ';}?>Regards.
If you want more than 10 just increase the number, for example, if you want 20 users then use "LIMIT 20".DAO class takes care of security. User class you used in your code is just an "extension" of DAO class.Regards.