print

Sample 1: Displaying User List

You are here: C97net3. Developer's Guide

A sample code to display user list.

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

Sample 1


There is no comment. Why not be the first?

read more More Comments/Post Your Own

Account

Search

Tags

acp add all also any create default display don download easy echo etc features field file files folder form function includes information init kemana link list may module name need number own page php please qengine read require script set site skin time tpl url use user using version welcome