This chapter gives you a sample on displaying the user list using qE. You will see how easy it is to work with qE.
test.tpl
<h1>Welcome to test page!</h1>
<!-- BEGINIF $login -->
<p>You are logged in as: {$current_user_id}</p>
<!-- ELSE -->
<p>You are not logged in.</p>
<!-- ENDIF -->
<table class="table_2" border="0">
<tr>
<th>User ID</th>
<th>Email</th>
<th>Level</th>
<th>Since</th>
<th>Notes</th>
</tr>
<!-- BEGINBLOCK list -->
<tr>
<td>{$user_id}</td>
<td>{$user_email}</td>
<td>{$user_level}</td>
<td>{$user_since}</td>
<td>{$user_notes}</td>
</tr>
<!-- ENDBLOCK -->
</table>
test.php
<?php
require './includes/user_init.php';
// now load the output tpl
$tpl = load_tpl ('test.tpl');
// all block output must be contained in $var['block_list']
// or any block_name defined
$txt['block_list'] = '';
// get entries from db
$res = sql_query ("SELECT * FROM ".$db_prefix."user ORDER BY user_id");
while ($row = sql_fetch_array ($res))
{
// convert the date from SQL format to human format
$row['user_since'] = convert_date ($row['user_since']);
// create the block
$txt['block_list'] .= quick_tpl ($tpl_block['list'], $row);
}
// output
$txt['main_body'] = quick_tpl ($tpl, $txt);
flush_tpl ();
?>
The Result
Subscribe to our newsletter for the latest updates and exciting promotions!
There are 1 replies on this comment