Location: PHPKode > projects > Hosting App > hosting/test.php
<?php

function search_users (& $tpl, $q, $what, $start, $limit)
{

$query = str_replace('+', ' ', $q);
$query = str_replace(',', ' ', $query);
$query = str_replace(':', ' ', $query);
$query = str_replace('%', ' ', $query);
	switch($what) { 
	
		case "ID" :

			$sql = "SELECT ID_client, Nom, Prenom, Login FROM $GLOBALS[tbl_client] WHERE ID_client = '".$query."' ";
//			echo $sql;
			break;
	
		case "name" : 

			$sql = "SELECT ID_client, Nom, Prenom, Login FROM $GLOBALS[tbl_client] WHERE Nom LIKE '%".$query."%' OR Prenom LIKE '%".$query."%'";

			break;

		case "user" : 

			$sql = "SELECT ID_client, Nom, Prenom, Login FROM $GLOBALS[tbl_client] WHERE Login LIKE '".$query."%'";

			break;

		case "company" :
			
			$sql = "SELECT ID_client, Nom, Prenom, Login FROM $GLOBALS[tbl_client] WHERE Rs LIKE '".$query."%'";
			
			break;
	
	} // switch	

	$res = mysql_query($sql) or die("query failed ".mysql_error());
	
	$total = mysql_num_rows($res);
	
	if (!$start) $start = 0;

		if ($total < $limit) {
		    $end = $total;
		}else{
			$end = $start + $limit;
		}

	$query = $sql." LIMIT".$start.", ".$limit;
	
	$result = mysql_query($query) or die("query failed ".mysql_error());

	
	$tpl -> MxText('body.main_bloc.start', $start + 1);

	$tpl -> MxText('body.main_bloc.limit', $end);

	$tpl -> MxText('body.main_bloc.total', $total);

	while($row = mysql_fetch_array($res)){

		$tpl -> MxText('body.main_bloc.view_loop.first_last', $row[2]." ".$row[1]);

		$tpl -> MxText('body.main_bloc.view_loop.login', $row[3]);

		$tpl -> MxText('body.main_bloc.view_loop.num_domains', count_user_domain($row[0]));

		$tpl -> MxUrl('body.main_bloc.view_loop.view', 'view.php', 'what=user&id='.$row[0]);

		$tpl -> MxUrl('body.main_bloc.view_loop.mod', 'modify.php', 'what=user&id='.$row[0]);

		$tpl -> MxUrl('body.main_bloc.view_loop.del', 'delete.php', 'what=user&user='.$row[3].'&id='.$row[0]);

		$tpl -> MxBloc('body.main_bloc.view_loop', "loop");

	} // while

	$tpl -> MxText('body.main_bloc.sep', '||');

	    if ($total > $end) {
			$tpl -> MxText('body.main_bloc.next', "next");
			$tpl -> MxUrl('body.main_bloc.next', $HTTP_ENV_VARS['SCRIPT_FILENAME'],"what=user&offset=".$end);
			}
			if ($start >= $limit) 
			{
			$s = $start - $limit;
			$tpl -> MxText('body.main_bloc.previous', "previous");
			$tpl -> MxUrl('body.main_bloc.previous', $HTTP_ENV_VARS['SCRIPT_FILENAME'],"what=user&offset=".$s);			
			}

} // end search function 



?>
Return current item: Hosting App