Location: PHPKode > scripts > alarisMenu > alarismenu/alarisAdmin/users.php
<?
/* 
 * User display and editing
 */

 
if(!isset($sort)){
 $sort = "desc";
}
if($sort == "asc"){
 $sort = "desc";
}else{
 $sort = "asc";
}

?>

<table width="590" cellpadding="0" cellspacing="1"  border="0">
   <tr>
    	<td width="110" class="titlebar">&nbsp;<b><a href="alarisAdmin.php?view=users&order=username&sort=<? echo $sort; ?>">Username</a></b></td>
        <td width="200" class="titlebar">&nbsp;<b><a href="alarisAdmin.php?view=users&order=firstname&sort=<? echo $sort; ?>">Firstname</a></b></td>
        <td width="200" class="titlebar">&nbsp;<b><a href="alarisAdmin.php?view=users&order=lastname&sort=<? echo $sort; ?>">Lastname</a></b></td>
        <td width="40" class="titlebar"><div align="center"><b>Edit</b></div></td>
        <td width="40" class="titlebar"><div align="center"><b>Delete</b></div></td>
   </tr>
</table>

<?
/*
 * Main table with display of database content in table 'alaris_users'
 */


if(!isset($order)){     // setting the order;
  $order = "username";
}

$query = "SELECT * FROM alaris_users ORDER BY $order $sort";
db_connect();
$result = sql_ask_and_answer($query);
$numrows = mysql_num_rows(mysql_query("SELECT * FROM alaris_users"));
db_close();
$bgcolor = "#cccc99";

/*
 * Return the table with all the data
 */

for($i=0; $i < count($result);$i++){
 if ($bgcolor == "#cccc99") {
 $bgcolor = "#ffffcc";
 } else {
 $bgcolor = "#cccc99";
 }
 extract($result[$i]);
 
 echo  "<table width=\"590\" cellpadding=\"0\" cellspacing=\"1\"  border=\"0\">"      
        ."<tr bgcolor=\"$bgcolor\">";
   echo  "<td width=\"110\">&nbsp;".$username."</td>"
        ."<td width=\"200\">&nbsp;".$firstname."</td>"
        ."<td width=\"200\">&nbsp;".$lastname."</td>";
        
   echo  "<td width=\"40\"><div align=\"center\"><a href=\"alarisAdmin.php?view=users&edit=".$user_id."\"><font color=\"darkred\">Edit</font></a></div></td>"; 
   echo  "<td width=\"40\"><div align=\"center\"><a onClick=\"return confirmSubmit();\" href=\"mysql_delete_users.php?delete=".$user_id."\"><font color=\"darkred\">Delete</font></a></div></td>";  
   echo  "</tr></table>";       
}


/* Return table for editing */

if(isset($edit) || isset($action)){
 if(isset($edit)){
  $display_user = get_user($edit);
 }
 ?>
        <form action="mysql_users.php" method="post" class="thin">
	<? if(isset($edit)) echo "<input type=\"hidden\" name=\"edit\" value=\"$edit\">"; ?>
	<table width="590" cellpadding="0" celspacing="0" border="0">
	 <tr>
	  <td valign="top" width="290">
		   <table width="290">
		    <tr>
		     <td>Firstname: </td>
		     <td><input type="text" class="textfield" name="firstname" value="<? echo $display_user[firstname]; ?>"></td>
		    </tr>	 
		    <tr>
		     <td>lastname: </td>
		     <td><input type="text" class="textfield" name="lastname" value="<? echo $display_user[lastname]; ?>"></td>
		    </tr>
		   </table>
	  </td>
	  <td valign="top" width="290">
		   <table width="290">
		    <tr>
		     <td>Username: </td>
		     <td><input type="text" class="textfield" name="username" value="<? echo $display_user[username]; ?>"></td>
		    </tr>
		    <tr>
		     <td>Password: </td>
		     <td><input type="text" class="textfield" name="password" value="<? echo $display_user[password]; ?>"></td>
		    </tr>
		   </table>
	  </td>
	 </tr>
	 <tr>
	  <td colspan=2><input class="button" type="Submit" value=<? isset($edit) ? print("Change") : print("Submit");?> >
	                <input class="button" type="Reset" value="Reset">
	     <? if(isset($edit)) print("&nbsp;<input class=\"button\" type=\"button\" value=\"New\" onclick=\"window.location='alarisAdmin.php?view=users&action=new'\">"); ?>
	  </td>
	 </tr>
	</table>  
	</form>

<?
}
?>
Return current item: alarisMenu