# Solved: Website noob needs assistance with PHP



## Guest (Oct 6, 2008)

Hello everyone,

I have a website (passed on to me by someone) which has a roster in it. Link: http://www.beluxvacc.org/index.php?option=com_wrapper&Itemid=64

As you can see it contains some names of our virtual air traffic controllers and many other things.

BUT (why oh why always is there a "BUT" )

I would like to add a column called "ELLX (Regional)", just like EBBR.
From admin point of view it looks like this ... (see attachment).
Basically , as you can see with EBBR, there should be an option "none, TWR and APP" also for ELLX. And the option should be shown in the roster on the website.

At the moment there is a module on our website with following code:

```
<?php
//Related Content//
/**
* Related Content Module
* @package Mambo
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.3 $
**/
 
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>
<p><font size="4" color="#004080"><br>
  <img src="../images/plane.jpg" width="20" height="15"> Belux vACC Controller 
  Roster</font></p>
<p class="text">Belux vACC Controllers who where active the last six months.
<br>(This list is updated manually)<br>
<b>TESTING</b>
<?
 
$option = trim( mosGetParam( $_REQUEST, 'option', null ) );
$task = trim( mosGetParam( $_REQUEST, 'task', null ) );
$id = intval( mosGetParam( $_REQUEST, 'id', null ) );
 
//if ($option == 'content' && $task == 'view' && $id) {
 
 $table_name = "members_belux";
 $where = " WHERE active = '1' ";
 // select the meta keywords from the item
 //$query = "SELECT metakey FROM mos_content WHERE id='$id'";
 $query = "SELECT fname, sname, vatsimid, rat_num, rating, info, staff, visiting, 
  active FROM $table_name".$where."ORDER BY fname ASC, sname ASC";
 
 $database->setQuery( $query );
 
 if ($data = trim( $database->loadResult() )) {
 print_r($data) ."<br>";
?>
	 <table class="datatable" >
  		<tr>
    		<th ><b>Name</b></th>
    		<th align=center><b>Rating</b></th>
    		<th align=center><b>Vatsim ID</b></th>
    		<th ><b>Remarks</b></th>
    		<th><b>Guest</b></th>
    		<th><b>Staff</b></th>
		  </tr>
<?
  foreach ( $data as $member )
  {
?>
	<tr>
	<td align=left><? echo "$member->fname $member->sname"; ?></td>
	<td align=center><? echo $member->rating; ?></td>
	<td align=center><a href="http://data.vatsim.net/stats/private/list3.html?id=<?php echo $member->vatsimid; ?>"  target="_blank"><?php echo $member->vatsimid; ?></a></td>
	<td align=left><?php echo $member->info; ?></td>
	<td align=center><?php if ($member->visiting == '1') { echo "X"; } ?></td>
	<td align=center><?php if ($member->staff == '1') { echo "X" ;} ?></td>
	</tr>
	
	<?php


  }

  //$date = $db->get_var("SELECT last_change FROM $table_name ORDER BY last_change DESC") ;
  //$date = substr($date, 8, 2)."-".substr($date, 5, 3).substr($date, 0, 4);
  
	?>
	</table> <?
 } else {
  echo "no data loaded";
 }
//}
?>
```
What do I have to change here in order to get this column ??
As you probably read in my post ... I know absolutly nothing about PHP so please be as specific and clear as possible

I hope you can help me out here

Regards

Vipersf


----------



## Guest (Oct 7, 2008)

bump


----------



## Techmonkeys (Feb 10, 2005)

Hi Viper,

How are you updating the list at the moment? say if you want to change one of the EBBR values from APP to TWR?

Do you manually change the html ? or is it in a form somewhere?

Basically, you need to store the info to go in the ELLX column in a database the call it using that module.

However I dont see in the module where the EBBR values come from ?


----------



## Guest (Oct 8, 2008)

McCabe,

- As you can see on the screen shot .. it's just a simply drop-down column on which you select the correct value.

-Where these values come from I do not know (it's my presedor who gave me the website) .. is it possible that it's coming from a SqlDatabase ? Because I have seen that we have one of those ....

Vipersf


----------



## Techmonkeys (Feb 10, 2005)

It will be an sql db, but even still to me it makes no sense as there is no column for EBBR listed in that code, but there is for the other columns

Is this the code as it is at the moment on your site or is this just the module as it is downloaded?.

Whoever did the site before may have modified this module slightly.

would need to see the modified file I think.


----------



## MMJ (Oct 15, 2006)

DMcCabe said:


> It will be an sql db, but even still to me it makes no sense as there is no column for EBBR listed in that code, but there is for the other columns
> 
> Is this the code as it is at the moment on your site or is this just the module as it is downloaded?.
> 
> ...


I too had a look and couldn't see the EBBR column in the code.


----------



## Guest (Oct 9, 2008)

This is the code as it is at the moment on my site.


----------



## Techmonkeys (Feb 10, 2005)

Sorry Viper, not trying to be a pain for you, but the code above can't be as it is on the website.

If you look at the code above you see this line:

```
<p class="text">Belux vACC Controllers who where active the last six months.
<br>(This list is updated manually)<br>
<b>TESTING</b>
```
then look at the site and you can see the *(This list is updated manually)* bit, but then nowhere on the page does it say *TESTING*. So it can't be using that code.

FTP to your website, then download this module directly.


----------



## Guest (Oct 9, 2008)

You'll probably kill me for this, but any advice on how to do this ??


----------



## Techmonkeys (Feb 10, 2005)

hehehehe 

I am guessing you do everything through front end at the moment, but do have any kind of access to upload and download files from the web site?#

You will normally have an ftp address something like:
ftp.beluxvacc.org
then a username and password to access it?

do you have these?

(dont tell me them lol, just want to know if you have the details)


----------



## Guest (Oct 9, 2008)

I think I found it:


```
roster.php 
HTML document text 
--------------------------------------------------------------------------------

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
all.clsMenuItemNS, .clsMenuItemIE{text-decoration: none; font: bold 12px Arial; color: white; cursor: hand; z-index:100}
#MainTable A:hover {color: yellow;}
</style>
<link rel="stylesheet" href="css/belux.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" class="text">
<p><font size="4" color="#004080"><br>
  <img src="../images/plane.jpg" width="20" height="15"> Belux vACC Controller 
  Roster</font></p>
<p class="text">Belux vACC Controllers who where active the last six months.
<br>(This list is updated manually)<br>
<?php 	
require_once "../bincludes/ez_sql.php";
$table_name = "members_belux";

if (isset($_GET['active'])) {
  if ($_GET['active'] == '1') {
    $list = "active";
    $where = " WHERE active = '1' ";
    echo "<a href='".$_SERVER['PHP_SELF']."?active=0' target='_self'>Show unactive controllers</a><br><br>";
  } elseif ($_GET['active'] == '0') {
    $list = "active";
    $where = " WHERE active <> '1' ";  
    echo "<a href='".$_SERVER['PHP_SELF']."?active=1' target='_self'>Show active controllers</a><br><br>";
  }
} else {
    $list = "active";
    $where = " WHERE active = '1' ";
    echo "<a href='".$_SERVER['PHP_SELF']."?active=0' target='_self'>Show unactive controllers</a><br><br>";
}

$sql = "SELECT fname, sname, vatsimid, rat_num, rating, ebbr, info, staff, visiting, 
  active FROM $table_name".$where."ORDER BY fname ASC, sname ASC";
  
if ($data = $db->get_results("$sql")) {
?>
	 <table class="datatable" >
  		<tr>
    		<th ><b>Name</b></th>
    		<th align=center><b>Rating</b></th>
    		<th align=center><b>EBBR</b></th>
    		<th align=center><b>Vatsim ID</b></th>
    		<th ><b>Remarks</b></th>
    		<th><b>Guest</b></th>
    		<th><b>Staff</b></th>
		  </tr>
<?
  foreach ( $data as $member )
  {
?>
	<tr>
	<td align=left><? echo "$member->fname $member->sname"; ?></td>
	<td align=center><? echo $member->rating; ?></td>
	<td align=left><?php echo $member->ebbr; ?></td>
	<td align=center><a href="http://data.vatsim.net/stats/private/list3.html?id=<?php echo $member->vatsimid; ?>"  target="_blank"><?php echo $member->vatsimid; ?></a></td>
	<td align=left><?php echo $member->info; ?></td>
	<td align=center><?php if ($member->visiting == '1') { echo "X"; } ?></td>
	<td align=center><?php if ($member->staff == '1') { echo "X" ;} ?></td>
	</tr>
	
	<?php


  }

  $date = $db->get_var("SELECT last_change FROM $table_name ORDER BY last_change DESC") ;
  $date = substr($date, 8, 2)."-".substr($date, 5, 3).substr($date, 0, 4);
  
	?>
	</table> <?

} else {

	echo "Sorry, no records were found!";	

}
?>

<hr>
<span class="updated">Last update: 
<!-- #BeginDate format:Am1 -->
<?php echo empty($date) ? "August 22, 2007" : $date; ?><!-- #EndDate -->
</span> 
</body>
</html>
```
Could this be the possible thing you were looking for ?


----------



## Techmonkeys (Feb 10, 2005)

Thats exactly it 

I have sent you a PM, let me know how you want to proceed


----------



## Guest (Oct 9, 2008)

Well it's not that I don't trust you, but I would really like to learn so that I do not have to contact you again when I have the same problem when adding a new column in a couple of weeks weeks/years ...

So I don't know ... what would be best for you


----------



## Techmonkeys (Feb 10, 2005)

ok I will write up some instructions, but bere with me this will not be straight forward lol


----------



## Techmonkeys (Feb 10, 2005)

ok no probs however there is one more file we need to see before I can tell you exactly what you need to do.

Tha page in the screenshot is an admin page whereby you can edit that table on your website and it's values.

I need to see the code behind that page too.


----------



## Guest (Oct 9, 2008)

I think this is what you are looking for ...

Please confirm !


```
members.php 
PHP script text 
--------------------------------------------------------------------------------

<?php
	require_once "../../bincludes/ez_sql.php";
  require_once("../../bincludes/validation_class.php");
  $table_name = "members_belux";
  
  function check_data($error = null) {
    if (isset($_POST['submit'])) {
      //echo "post delete ".$_POST['delete']." <br>";
      if ($_POST['submit'] == "Delete") {
        $example = new Validate_fields;
        $example->add_num_field("ID", $_POST['ID'], "number", "y", 0);
        if ($example->validation()) {
          $error = "WHERE id = '".$_GET['id']."'";
          return $error;
          exit;          
        }
      }
      $example = new Validate_fields;
      //$example->check_4html = true;
      if ($_POST['act'] == "Update") {
        $example->add_num_field("ID", $_POST['ID'], "number", "y", 0);
      }
      $example->add_text_field("Lastname", $_POST['sname'], "text", "y", 20);
      $example->add_text_field("Firstname", $_POST['fname'], "text", "y", 20);
      $example->add_num_field("Vatsim ID", $_POST['vatsimid'], "number", "y", 0, 7);
      //$example->add_num_field("Visiting controller", $_POST['visiting'], "number", "n", 0, 1);
      //$example->add_num_field("Staff", $_POST['staff'], "number", "n", 0, 1);
      //$example->add_num_field("Active", $_POST['active'], "number", "n", 0, 1);
      $example->add_link_field("E-mail", $_POST['email'], "email", "n");
      $example->add_text_field("Rating", $_POST['rating'], "text", "y", 20);
      $ebbr = $_POST['ebbr'];
      if ($ebbr == "None") { $ebbr = ""; };
      $example->add_text_field("EBBR", $ebbr, "text", "n", 3);
      $example->add_text_field("Remark", $_POST['info'], "text", "n", 40);
      if ($example->validation()) {
      	$error = ""; // replace this text if you like...
        $info = $_POST['info'];
        if (empty($info)) { $info = "No remarks"; }
        $visiting = $_POST['visiting'];
        if ($visiting == "1") { $visiting = "1"; } else { $visiting = "0"; }
        $staff = $_POST['staff'];
        if ($staff == "1") { $staff = "1"; } else { $staff = "0"; }
        $active = $_POST['active'];
        if ($active == "1") { $active = "1"; } else { $active = "0"; }
      	$edited = date('Y-m-d');
        $sname = $example->stripit($_POST['sname']);
        $fname = $example->stripit($_POST['fname']);
     	  $rating_list = array ('1' => 'Pilot / Observer', '2' => 'Student', '3' => 'Senior Student', 
          '4' => 'Controller', '5' => 'Senior Controller', '6' => 'Instructor', '7' => 'Senior Instructor', 
          '8' => 'Supervisor', '9' => 'Administration');
        //$key = array_search('green', $array);
        $rat_num = array_search($_POST['rating'], $rating_list);
        $rating = $rating_list[$rat_num];
        $id = $_POST['ID'];
        if ($_POST['act'] == "Update") {
          $error =  "SET sname = '$sname', fname = '$fname', rat_num = '$rat_num', ebbr = '$ebbr', info = '$info',
            visiting = '$visiting', staff = '$staff',  active = '$active', email = '".$_POST['email']."',
            vatsimid = '".$_POST['vatsimid']."', rating = '$rating' WHERE id = $id";
          //echo "rating: $rating <br>";
          //echo "$sname <br>";
          return $error;
          exit; 
        } elseif ($_POST['act'] == "Add") {
          $error = "(sname, fname, rat_num, info, vatsimid, rating, ebbr, sub_date, email, staff,
            visiting, active) VALUES ('$sname', '$fname', '$ratnum', '$info', 
            '".$_POST['vatsimid']."', '$rating', '$ebbr', '$edited', '".$_POST['email']."', '$staff',
            '$visiting', '$active' )";
          return $error;
          exit;          
        }
    	 } else {
    		$error = $example->create_msg();
    		return $error;
    	}      
    }
  }

  function form ($user = NULL, $action) {
    echo "<hr><b><font color=#000066 size=2 face='Verdana, Arial, Helvetica, sans-serif'>
          <div align='center'>";
         
    echo ($action==Update) ? "Update current values with:" : "Add a new record";
    echo "<br>";
  	echo ($action==Update) ? "<img src='http://online.vatsimindicators.net/" : "";
    echo empty($_POST['vatsimid']) ? $user->vatsimid : $_POST['vatsimid'];
    echo "/5417.png'><br>";
?>    
    </div></font></b>
	  <form method='post'>
	  <table width='80%' border='0' cellspacing='0' cellpadding='0' align='center'>
  		<tr>
				<td align=left valign=top>ID</td>
				<td>
				<?php echo empty($_POST['ID']) ? $user->id : $_POST['ID']; ?>
				<input type='hidden' name='ID' value=<?php echo empty($_POST['ID']) ? $user->id : $_POST['ID']; ?>></td></tr>
			<tr><td align=left>First Name</td>			
				<td><input type='text' name='fname' size='40' value='<?php echo empty($_POST['fname']) ? stripslashes($user->fname) : $_POST['fname']; ?>'></td></tr>
			<tr><td align=left>Last Name</td>			
				<td><input type='text' name='sname' size='40' value='<?php echo empty($_POST['sname']) ? stripslashes($user->sname) : $_POST['sname']; ?>'></td></tr>
			<tr><td align=left>Vatsim ID</td>			
				<td><input type='text' name='vatsimid' size='8' value='<?php echo empty($_POST['vatsimid']) ? $user->vatsimid : $_POST['vatsimid']; ?>'>
        <A HREF="http://data.vatsim.net/stats/private/list3.html?id=<? echo $user->vatsimid; ?>"
          target="_blank"><? echo $user->vatsimid; ?></A></td></tr>
			<tr><td align=left>Rating</td>			
				<td><select name='rating'>
				
<?php 
    	$rating_list = array ('1' => 'Pilot / Observer', '2' => 'Student', '3' => 'Senior Student', 
      '4' => 'Controller', '5' => 'Senior Controller', '6' => 'Instructor', '7' => 'Senior Instructor', 
      '8' => 'Supervisor', '9' => 'Administration');

      if (!$_POST['rating']) {
        $rating = $user->rating;
      } else {
        $rating = $_POST['rating'];
      } 
      
      foreach ($rating_list as $rat)
      {
        if ($rating == $rat) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$rat</option>";
      }
?>                  
				</select></td></tr>
			<tr><td align=left>EBBR</td>
        <td><select name='ebbr'>
<?php 
    	$ebbr_list = array ('1' => 'None', '2' => 'TWR', '3' => 'APP');

      if (!$_POST['ebbr']) {
        $ebbr = $user->ebbr;
      } else {
        $ebbr = $_POST['ebbr'];
      } 
      
      foreach ($ebbr_list as $qual)
      {
        if ($ebbr == $qual) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$qual</option>";
      }
?>                  
				</select></td></tr>         			
			<tr><td align=left>E-mail</td>			
				<td><input type='text' name='email' size='50' value='<?php echo empty($_POST['email']) ? $user->email : $_POST['email']; ?>'></td></tr>
			<tr><td align=left>Active ?</td>			
				<td><input type="checkbox" name='active' value='1' <?php if ($_POST['active'] == '1' || $user->active == '1' ) { echo "CHECKED";} ?>>
        Has this controller been online as ATC the last 6 months ?</td></tr>
			<tr><td align=left>Visiting ?</td>			
			  <td><input type='checkbox' name='visiting' value='1' <?php if ($_POST['visiting'] == '1' || $user->visiting == '1' ) { echo "CHECKED";} ?>>
        Visiting Controller ?</td></tr>
			<tr><td align=left>Staff ?</td>			
				<td><input type='checkbox' name='staff' value='1' <?php if ($_POST['staff'] == '1' || $user->staff == '1' ) { echo "CHECKED";} ?>>
        Belux Staff member ?</td></tr>
			<tr><td align=left>Remark <b>(published!)</b></td>			
				<td><input type='text' name='info' size='50' value='<?php echo empty($_POST['info']) ? $user->info : $_POST['info']; ?>'></td></tr>
			<tr><td align=left>Registration Date</td>			
        <td><?php echo empty($_POST['sub_date']) ? $user->sub_date : $_POST['sub_date']; ?></td></tr>								
			<tr><td align=left>Last change</td>			
        <td><?php echo empty($_POST['last_change']) ? $user->last_change : $_POST['last_change']; ?>			
				</td>
			</tr>
				<?php				
				echo "<p align='center'><input type='submit' value='Submit' name='submit'>";
				if ($action=="Update") {
          echo "<input type='submit' value='Delete' name='submit'>";
        }
				echo "<input name='act' type='hidden' value='$action'>";
				?>
		      </form>
      </table>
<?
		}

		function listing_item ($users) {
			GLOBAL $PHP_SELF;
        echo "<TR>
        	<TH>Name</TH>
        	<TH>Vatsim ID</TH>
        	<TH>Rating</TH>
        	<TH>EBBR</TH>
        	<TH>Edit</TH>
        	<th>Active</th>
        	<th>Visit</th>
        	<th>Staff</th>
        </TR>";
      foreach ( $users as $user )
      {
?>
        	<TD><A HREF="mailto:<? echo $user->email; ?>"><? echo $user->fname." ".$user->sname; ?></a></TD>
        	<TD align="center"><A HREF="http://data.vatsim.net/stats/private/list3.html?id=<? echo $user->vatsimid; ?>"
              target="_blank"><? echo $user->vatsimid; ?></A></TD>
        	<TD><? echo $user->rating; ?></TD>
        	<TD><? echo $user->ebbr; ?></TD>
        	<TD><A HREF="<? echo $PHP_SELF."?action=edit&id=".$user->id; ?>">edit</A></TD>
        	<td align="center"><?php echo ($user->active == '1') ? "X" : ""; ?></td>
        	<td align="center"><?php echo ($user->visiting == '1') ? "X" : ""; ?></td>
        	<td align="center"><?php echo ($user->staff == '1') ? "X" : ""; ?></td>
        	<!-- TD><A HREF="<? //echo $PHP_SELF."?action=delete&id=".$user['id']; ?>">delete</A></TD -->
        	<!-- TD><A HREF="<? //echo $PHP_SELF."?action=".$endis."&id=".$data['id']."\">".$endis; ?></A></TD -->
        </TR>
<?
      }
		}

	// Start of actual program...

	$action = (isset($_GET['action'])) ? $_GET['action'] : "none";

	echo "<HTML>\n<head>\n<link rel='stylesheet' type='text/css' href='../../css/belux.css'>
        \n</head>\n<BODY class='text'>\n<CENTER>\n
	      <a href='../staff.htm'>Staff Main</a> - 
        <A HREF=".$_SERVER['PHP_SELF'].">List All</A> - 
        <A HREF=".$PHP_SELF."?action=add>Add Entry</A><P>\n<TABLE class='datatable'>\n\n";
  $member_list = "SELECT id, sname, fname, vatsimid, rating, ebbr, active, visiting, staff, email 
              FROM $table_name ORDER by fname ASC, sname ASC";
	switch ($action) {
		case "add":
			switch ($_SERVER['REQUEST_METHOD']) {
				case "POST":
				  $error = check_data($error);
				  if (substr($error, 0, 6) == "(sname") {
				    $sql = "INSERT INTO $table_name ".$error;
				    $db->query("$sql");
				    //$db->debug();
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } else {
				    echo $error;
				    $data = "";
  					form($data, 'Add');
          }
					break;
				case "GET":
				    $data = "";
  					form($data, 'Add');
					break;
			}
			//$CP->add();
			break;
		case "edit":
			//$CP->edit();
			switch ($_SERVER['REQUEST_METHOD']) {
				case "POST":
				  $error = check_data($error);
				  if (substr($error, 0, 4) == "SET ") {
				    $sql = "UPDATE $table_name ".$error;
				    $db->query("$sql");
				    //$db->debug();
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } elseif (substr($error, 0, 6) == "WHERE ") {
            $sql = "DELETE FROM $table_name ".$error;
          	$db->query("$sql");
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } else {
				    echo $error;
				    $data = "";
  					form($data, 'Update');
          }
					break;
				case "GET":
					$id = (empty($_GET['id'])) ? "" : $_GET['id'];
          $data = $db->get_row("SELECT id, sname, fname, vatsimid, rating, ebbr,  
            info, last_change, active, visiting, staff, sub_date, email 
            FROM $table_name WHERE id = $id");
					form($data, 'Update');
					break;
			}
			break;
		case "delete":
			//$CP->delete();
			break;
		case "enable":
			//$CP->enable();
			break;
		case "disable":
			//$CP->disable();
			break;
		default:
			//$data = $db->get_results("SELECT id, sname, fname, vatsimid, rating FROM $table_name");
			$data = $db->get_results("$member_list");
			/*echo "<pre>";
      print_r ($users);
      echo "</pre>"; */
			listing_item($data);
	}

	echo "\n\n</TABLE>\n</CENTER>\n</BODY>\n</HTML>";
?>
```


----------



## Techmonkeys (Feb 10, 2005)

Thats the one 

Right I would genuinely suggest seeing as this is not something you are 100% comfortable with that you make a copy of your existing website and database as it is now.

Download all the files for your site and also do a back up of the database, so that any changes we make now can be rectified.

------------------------------------------------------------------------------------------------------------
Ok here goes:

*Part 1 - Editing the database*
First you need to access the control panel (cpanel) of your website by going to this address: http://www.beluxvacc.org:2082/

Enter the same username and password you did to access the FTP earlier.

Now click the icon that's called "MySQL® Databases", once in the next screen (where you will see all the databases on your server) scroll right to the bottom and click on the link that says "phpMyAdmin".

You are now in the mySQL database editting tool PHPMyAdmin. Now click on the name of your database in the left hand menu (the database is probably called "mambo" or "Belux" , but I cant tell you that bit for sure).

Once your in the database find the table in the menu on the left called "members_belux" and click on it.

This will now take you to the table structure, you should see a list of field names such as fname, sname, vatsimid, rat_num, rating, ebbr, info, staff, visiting and active.

Below this list you should see a box that says "Add [ 1 ] field(s) " leave the number as 1, then make sure you have selected "At end of table" then click the GO button at the end of the line.

You now need to fill in the details of the field.

Fill in the values as this:
Field Name: ellx
Type: VARCHAR
Lenght/Values: 10

Leave everything else as is and click "SAVE" at the bottom right.

You will now be presented with the list of fields again, this time you will have the *ellx* field at the bottom.

*Part 2 - Changing the roster.php*

Replace the content of your roster.php with this:


```
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
all.clsMenuItemNS, .clsMenuItemIE{text-decoration: none; font: bold 12px Arial; color: white; cursor: hand; z-index:100}
#MainTable A:hover {color: yellow;}
</style>
<link rel="stylesheet" href="css/belux.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" class="text">
<p><font size="4" color="#004080"><br>
  <img src="../images/plane.jpg" width="20" height="15"> Belux vACC Controller 
  Roster</font></p>
<p class="text">Belux vACC Controllers who where active the last six months.
<br>(This list is updated manually)<br>
<?php 	
require_once "../bincludes/ez_sql.php";
$table_name = "members_belux";

if (isset($_GET['active'])) {
  if ($_GET['active'] == '1') {
    $list = "active";
    $where = " WHERE active = '1' ";
    echo "<a href='".$_SERVER['PHP_SELF']."?active=0' target='_self'>Show unactive controllers</a><br><br>";
  } elseif ($_GET['active'] == '0') {
    $list = "active";
    $where = " WHERE active <> '1' ";  
    echo "<a href='".$_SERVER['PHP_SELF']."?active=1' target='_self'>Show active controllers</a><br><br>";
  }
} else {
    $list = "active";
    $where = " WHERE active = '1' ";
    echo "<a href='".$_SERVER['PHP_SELF']."?active=0' target='_self'>Show unactive controllers</a><br><br>";
}

$sql = "SELECT fname, sname, vatsimid, rat_num, rating, ebbr, ellx, info, staff, visiting, 
  active FROM $table_name".$where."ORDER BY fname ASC, sname ASC";
  
if ($data = $db->get_results("$sql")) {
?>
	 <table class="datatable" >
  		<tr>
    		<th ><b>Name</b></th>
    		<th align=center><b>Rating</b></th>
    		<th align=center><b>EBBR</b></th>
			<th align=center><b>ELLX</b></th>
    		<th align=center><b>Vatsim ID</b></th>
    		<th ><b>Remarks</b></th>
    		<th><b>Guest</b></th>
    		<th><b>Staff</b></th>
		  </tr>
<?
  foreach ( $data as $member )
  {
?>
	<tr>
	<td align=left><? echo "$member->fname $member->sname"; ?></td>
	<td align=center><? echo $member->rating; ?></td>
	<td align=left><?php echo $member->ebbr; ?></td>
	<td align=left><?php echo $member->ellx; ?></td>
	<td align=center><a href="http://data.vatsim.net/stats/private/list3.html?id=<?php echo $member->vatsimid; ?>"  target="_blank"><?php echo $member->vatsimid; ?></a></td>
	<td align=left><?php echo $member->info; ?></td>
	<td align=center><?php if ($member->visiting == '1') { echo "X"; } ?></td>
	<td align=center><?php if ($member->staff == '1') { echo "X" ;} ?></td>
	</tr>
	
	<?php


  }

  $date = $db->get_var("SELECT last_change FROM $table_name ORDER BY last_change DESC") ;
  $date = substr($date, 8, 2)."-".substr($date, 5, 3).substr($date, 0, 4);
  
	?>
	</table> <?

} else {

	echo "Sorry, no records were found!";	

}
?>

<hr>
<span class="updated">Last update: 
<!-- #BeginDate format:Am1 -->
<?php echo empty($date) ? "August 22, 2007" : $date; ?><!-- #EndDate -->
</span> 
</body>
</html>
```
*Part 3 - Replace your members.php code with this:*

```
<?php
	require_once "../../bincludes/ez_sql.php";
  require_once("../../bincludes/validation_class.php");
  $table_name = "members_belux";
  
  function check_data($error = null) {
    if (isset($_POST['submit'])) {
      //echo "post delete ".$_POST['delete']." <br>";
      if ($_POST['submit'] == "Delete") {
        $example = new Validate_fields;
        $example->add_num_field("ID", $_POST['ID'], "number", "y", 0);
        if ($example->validation()) {
          $error = "WHERE id = '".$_GET['id']."'";
          return $error;
          exit;          
        }
      }
      $example = new Validate_fields;
      //$example->check_4html = true;
      if ($_POST['act'] == "Update") {
        $example->add_num_field("ID", $_POST['ID'], "number", "y", 0);
      }
      $example->add_text_field("Lastname", $_POST['sname'], "text", "y", 20);
      $example->add_text_field("Firstname", $_POST['fname'], "text", "y", 20);
      $example->add_num_field("Vatsim ID", $_POST['vatsimid'], "number", "y", 0, 7);
      //$example->add_num_field("Visiting controller", $_POST['visiting'], "number", "n", 0, 1);
      //$example->add_num_field("Staff", $_POST['staff'], "number", "n", 0, 1);
      //$example->add_num_field("Active", $_POST['active'], "number", "n", 0, 1);
      $example->add_link_field("E-mail", $_POST['email'], "email", "n");
      $example->add_text_field("Rating", $_POST['rating'], "text", "y", 20);
      $ebbr = $_POST['ebbr'];
      if ($ebbr == "None") { $ebbr = ""; };
      $example->add_text_field("EBBR", $ebbr, "text", "n", 3);
      $ellx = $_POST['ellx'];
      if ($ellx == "None") { $ellx = ""; };
      $example->add_text_field("ELLX", $ellx, "text", "n", 3);
      $example->add_text_field("Remark", $_POST['info'], "text", "n", 40);
      if ($example->validation()) {
      	$error = ""; // replace this text if you like...
        $info = $_POST['info'];
        if (empty($info)) { $info = "No remarks"; }
        $visiting = $_POST['visiting'];
        if ($visiting == "1") { $visiting = "1"; } else { $visiting = "0"; }
        $staff = $_POST['staff'];
        if ($staff == "1") { $staff = "1"; } else { $staff = "0"; }
        $active = $_POST['active'];
        if ($active == "1") { $active = "1"; } else { $active = "0"; }
      	$edited = date('Y-m-d');
        $sname = $example->stripit($_POST['sname']);
        $fname = $example->stripit($_POST['fname']);
     	  $rating_list = array ('1' => 'Pilot / Observer', '2' => 'Student', '3' => 'Senior Student', 
          '4' => 'Controller', '5' => 'Senior Controller', '6' => 'Instructor', '7' => 'Senior Instructor', 
          '8' => 'Supervisor', '9' => 'Administration');
        //$key = array_search('green', $array);
        $rat_num = array_search($_POST['rating'], $rating_list);
        $rating = $rating_list[$rat_num];
        $id = $_POST['ID'];
        if ($_POST['act'] == "Update") {
          $error =  "SET sname = '$sname', fname = '$fname', rat_num = '$rat_num', ebbr = '$ebbr', ellx = '$ellx', info = '$info',
            visiting = '$visiting', staff = '$staff',  active = '$active', email = '".$_POST['email']."',
            vatsimid = '".$_POST['vatsimid']."', rating = '$rating' WHERE id = $id";
          //echo "rating: $rating <br>";
          //echo "$sname <br>";
          return $error;
          exit; 
        } elseif ($_POST['act'] == "Add") {
          $error = "(sname, fname, rat_num, info, vatsimid, rating, ebbr, ellx, sub_date, email, staff,
            visiting, active) VALUES ('$sname', '$fname', '$ratnum', '$info', 
            '".$_POST['vatsimid']."', '$rating', '$ebbr', '$ellx, '$edited', '".$_POST['email']."', '$staff',
            '$visiting', '$active' )";
          return $error;
          exit;          
        }
    	 } else {
    		$error = $example->create_msg();
    		return $error;
    	}      
    }
  }

  function form ($user = NULL, $action) {
    echo "<hr><b><font color=#000066 size=2 face='Verdana, Arial, Helvetica, sans-serif'>
          <div align='center'>";
         
    echo ($action==Update) ? "Update current values with:" : "Add a new record";
    echo "<br>";
  	echo ($action==Update) ? "<img src='http://online.vatsimindicators.net/" : "";
    echo empty($_POST['vatsimid']) ? $user->vatsimid : $_POST['vatsimid'];
    echo "/5417.png'><br>";
?>    
    </div></font></b>
	  <form method='post'>
	  <table width='80%' border='0' cellspacing='0' cellpadding='0' align='center'>
  		<tr>
				<td align=left valign=top>ID</td>
				<td>
				<?php echo empty($_POST['ID']) ? $user->id : $_POST['ID']; ?>
				<input type='hidden' name='ID' value=<?php echo empty($_POST['ID']) ? $user->id : $_POST['ID']; ?>></td></tr>
			<tr><td align=left>First Name</td>			
				<td><input type='text' name='fname' size='40' value='<?php echo empty($_POST['fname']) ? stripslashes($user->fname) : $_POST['fname']; ?>'></td></tr>
			<tr><td align=left>Last Name</td>			
				<td><input type='text' name='sname' size='40' value='<?php echo empty($_POST['sname']) ? stripslashes($user->sname) : $_POST['sname']; ?>'></td></tr>
			<tr><td align=left>Vatsim ID</td>			
				<td><input type='text' name='vatsimid' size='8' value='<?php echo empty($_POST['vatsimid']) ? $user->vatsimid : $_POST['vatsimid']; ?>'>
        <A HREF="http://data.vatsim.net/stats/private/list3.html?id=<? echo $user->vatsimid; ?>"
          target="_blank"><? echo $user->vatsimid; ?></A></td></tr>
			<tr><td align=left>Rating</td>			
				<td><select name='rating'>
				
<?php 
    	$rating_list = array ('1' => 'Pilot / Observer', '2' => 'Student', '3' => 'Senior Student', 
      '4' => 'Controller', '5' => 'Senior Controller', '6' => 'Instructor', '7' => 'Senior Instructor', 
      '8' => 'Supervisor', '9' => 'Administration');

      if (!$_POST['rating']) {
        $rating = $user->rating;
      } else {
        $rating = $_POST['rating'];
      } 
      
      foreach ($rating_list as $rat)
      {
        if ($rating == $rat) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$rat</option>";
      }
?>                  
				</select></td></tr>
			<tr><td align=left>EBBR</td>
        <td><select name='ebbr'>
<?php 
    	$ebbr_list = array ('1' => 'None', '2' => 'TWR', '3' => 'APP'); 

      if (!$_POST['ebbr']) {
        $ebbr = $user->ebbr;
      } else {
        $ebbr = $_POST['ebbr'];
      } 
      
      foreach ($ebbr_list as $qual)
      {
        if ($ebbr == $qual) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$qual</option>";
      }
?>                  
				</select></td></tr>    
<?php

    	$ellx_list = array ('1' => 'None', '2' => 'TWR', '3' => 'APP'); //*************Add you extra options for the ELLX drop down here.***************

      if (!$_POST['ellx']) {
        $ellx = $user->ellx;
      } else {
        $ellx = $_POST['ellx'];
      } 
      
      foreach ($ellx_list as $qual)
      {
        if ($ellx == $qual) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$qual</option>";
      }
?>                  
				</select></td></tr>      			
			<tr><td align=left>E-mail</td>			
				<td><input type='text' name='email' size='50' value='<?php echo empty($_POST['email']) ? $user->email : $_POST['email']; ?>'></td></tr>
			<tr><td align=left>Active ?</td>			
				<td><input type="checkbox" name='active' value='1' <?php if ($_POST['active'] == '1' || $user->active == '1' ) { echo "CHECKED";} ?>>
        Has this controller been online as ATC the last 6 months ?</td></tr>
			<tr><td align=left>Visiting ?</td>			
			  <td><input type='checkbox' name='visiting' value='1' <?php if ($_POST['visiting'] == '1' || $user->visiting == '1' ) { echo "CHECKED";} ?>>
        Visiting Controller ?</td></tr>
			<tr><td align=left>Staff ?</td>			
				<td><input type='checkbox' name='staff' value='1' <?php if ($_POST['staff'] == '1' || $user->staff == '1' ) { echo "CHECKED";} ?>>
        Belux Staff member ?</td></tr>
			<tr><td align=left>Remark <b>(published!)</b></td>			
				<td><input type='text' name='info' size='50' value='<?php echo empty($_POST['info']) ? $user->info : $_POST['info']; ?>'></td></tr>
			<tr><td align=left>Registration Date</td>			
        <td><?php echo empty($_POST['sub_date']) ? $user->sub_date : $_POST['sub_date']; ?></td></tr>								
			<tr><td align=left>Last change</td>			
        <td><?php echo empty($_POST['last_change']) ? $user->last_change : $_POST['last_change']; ?>			
				</td>
			</tr>
				<?php				
				echo "<p align='center'><input type='submit' value='Submit' name='submit'>";
				if ($action=="Update") {
          echo "<input type='submit' value='Delete' name='submit'>";
        }
				echo "<input name='act' type='hidden' value='$action'>";
				?>
		      </form>
      </table>
<?
		}

		function listing_item ($users) {
			GLOBAL $PHP_SELF;
        echo "<TR>
        	<TH>Name</TH>
        	<TH>Vatsim ID</TH>
        	<TH>Rating</TH>
        	<TH>EBBR</TH>
			<TH>ELLX</TH>
        	<TH>Edit</TH>
        	<th>Active</th>
        	<th>Visit</th>
        	<th>Staff</th>
        </TR>";
      foreach ( $users as $user )
      {
?>
        	<TD><A HREF="mailto:<? echo $user->email; ?>"><? echo $user->fname." ".$user->sname; ?></a></TD>
        	<TD align="center"><A HREF="http://data.vatsim.net/stats/private/list3.html?id=<? echo $user->vatsimid; ?>"
              target="_blank"><? echo $user->vatsimid; ?></A></TD>
        	<TD><? echo $user->rating; ?></TD>
        	<TD><? echo $user->ebbr; ?></TD>
			<TD><? echo $user->ellx; ?></TD>
        	<TD><A HREF="<? echo $PHP_SELF."?action=edit&id=".$user->id; ?>">edit</A></TD>
        	<td align="center"><?php echo ($user->active == '1') ? "X" : ""; ?></td>
        	<td align="center"><?php echo ($user->visiting == '1') ? "X" : ""; ?></td>
        	<td align="center"><?php echo ($user->staff == '1') ? "X" : ""; ?></td>
        	<!-- TD><A HREF="<? //echo $PHP_SELF."?action=delete&id=".$user['id']; ?>">delete</A></TD -->
        	<!-- TD><A HREF="<? //echo $PHP_SELF."?action=".$endis."&id=".$data['id']."\">".$endis; ?></A></TD -->
        </TR>
<?
      }
		}

	// Start of actual program...

	$action = (isset($_GET['action'])) ? $_GET['action'] : "none";

	echo "<HTML>\n<head>\n<link rel='stylesheet' type='text/css' href='../../css/belux.css'>
        \n</head>\n<BODY class='text'>\n<CENTER>\n
	      <a href='../staff.htm'>Staff Main</a> - 
        <A HREF=".$_SERVER['PHP_SELF'].">List All</A> - 
        <A HREF=".$PHP_SELF."?action=add>Add Entry</A><P>\n<TABLE class='datatable'>\n\n";
  $member_list = "SELECT id, sname, fname, vatsimid, rating, ebbr, ellx, active, visiting, staff, email 
              FROM $table_name ORDER by fname ASC, sname ASC";
	switch ($action) {
		case "add":
			switch ($_SERVER['REQUEST_METHOD']) {
				case "POST":
				  $error = check_data($error);
				  if (substr($error, 0, 6) == "(sname") {
				    $sql = "INSERT INTO $table_name ".$error;
				    $db->query("$sql");
				    //$db->debug();
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } else {
				    echo $error;
				    $data = "";
  					form($data, 'Add');
          }
					break;
				case "GET":
				    $data = "";
  					form($data, 'Add');
					break;
			}
			//$CP->add();
			break;
		case "edit":
			//$CP->edit();
			switch ($_SERVER['REQUEST_METHOD']) {
				case "POST":
				  $error = check_data($error);
				  if (substr($error, 0, 4) == "SET ") {
				    $sql = "UPDATE $table_name ".$error;
				    $db->query("$sql");
				    //$db->debug();
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } elseif (substr($error, 0, 6) == "WHERE ") {
            $sql = "DELETE FROM $table_name ".$error;
          	$db->query("$sql");
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } else {
				    echo $error;
				    $data = "";
  					form($data, 'Update');
          }
					break;
				case "GET":
					$id = (empty($_GET['id'])) ? "" : $_GET['id'];
          $data = $db->get_row("SELECT id, sname, fname, vatsimid, rating, ebbr,  ellx,
            info, last_change, active, visiting, staff, sub_date, email 
            FROM $table_name WHERE id = $id");
					form($data, 'Update');
					break;
			}
			break;
		case "delete":
			//$CP->delete();
			break;
		case "enable":
			//$CP->enable();
			break;
		case "disable":
			//$CP->disable();
			break;
		default:
			//$data = $db->get_results("SELECT id, sname, fname, vatsimid, rating FROM $table_name");
			$data = $db->get_results("$member_list");
			/*echo "<pre>";
      print_r ($users);
      echo "</pre>"; */
			listing_item($data);
	}

	echo "\n\n</TABLE>\n</CENTER>\n</BODY>\n</HTML>";
?>
```
To see the changes in the code that i have made simply search the word "ellx"

Also note the line


```
$ellx_list = array ('1' => 'None', '2' => 'TWR', '3' => 'APP'); //*************Add you extra options for the ELLX drop down here.***************
```
This is where you would add new options for the drop down list. So if you wanted another list option for "techguy" you would add


```
$ellx_list = array ('1' => 'None', '2' => 'TWR', '3' => 'APP', '4' => 'techguy');

Try the code and let me know how it goes.
```


----------



## Guest (Oct 10, 2008)

Thx, I will try this ASAP (somewhere tomorrow).
I will keep you posted.
Thank you so far ...


----------



## Guest (Oct 11, 2008)

I've got good news and bad news.

I'll start with the good news:

1) my website didn't crash !
2) I can see the ELLX column when logging in as admin to edit the roster.

The bad news:
1) I don't see the column ELLX when I just take a look at the roster (without being logged in as admin), though this might be related the the following:
2) The ELLX has no dropdown menu, the options are just there as text (see attachment!)

DMcCabe, your instructions were great so far ... care to help me out with these small errors ?


----------



## Guest (Oct 11, 2008)

I've been taking a look at the codes and found some minor error like: forgetting a ´ etc. etc.
Yet the roblems still persists.

I have posted the two codes as they are currently in my website below.


```
members.php 
PHP script text 
--------------------------------------------------------------------------------

<?php
	require_once "../../bincludes/ez_sql.php";
  require_once("../../bincludes/validation_class.php");
  $table_name = "members_belux";
  
  function check_data($error = null) {
    if (isset($_POST['submit'])) {
      //echo "post delete ".$_POST['delete']." <br>";
      if ($_POST['submit'] == "Delete") {
        $example = new Validate_fields;
        $example->add_num_field("ID", $_POST['ID'], "number", "y", 0);
        if ($example->validation()) {
          $error = "WHERE id = '".$_GET['id']."'";
          return $error;
          exit;          
        }
      }
      $example = new Validate_fields;
      //$example->check_4html = true;
      if ($_POST['act'] == "Update") {
        $example->add_num_field("ID", $_POST['ID'], "number", "y", 0);
      }
      $example->add_text_field("Lastname", $_POST['sname'], "text", "y", 20);
      $example->add_text_field("Firstname", $_POST['fname'], "text", "y", 20);
      $example->add_num_field("Vatsim ID", $_POST['vatsimid'], "number", "y", 0, 7);
      //$example->add_num_field("Visiting controller", $_POST['visiting'], "number", "n", 0, 1);
      //$example->add_num_field("Staff", $_POST['staff'], "number", "n", 0, 1);
      //$example->add_num_field("Active", $_POST['active'], "number", "n", 0, 1);
      $example->add_link_field("E-mail", $_POST['email'], "email", "n");
      $example->add_text_field("Rating", $_POST['rating'], "text", "y", 20);
      $ebbr = $_POST['ebbr'];
      if ($ebbr == "None") { $ebbr = ""; };
      $example->add_text_field("EBBR", $ebbr, "text", "n", 3);
      $ellx = $_POST['ellx'];
      if ($ellx == "None") { $ellx = ""; };
      $example->add_text_field("ELLX", $ellx, "text", "n", 3);
      $example->add_text_field("Remark", $_POST['info'], "text", "n", 40);
      if ($example->validation()) {
      	$error = ""; // replace this text if you like...
        $info = $_POST['info'];
        if (empty($info)) { $info = "No remarks"; }
        $visiting = $_POST['visiting'];
        if ($visiting == "1") { $visiting = "1"; } else { $visiting = "0"; }
        $staff = $_POST['staff'];
        if ($staff == "1") { $staff = "1"; } else { $staff = "0"; }
        $active = $_POST['active'];
        if ($active == "1") { $active = "1"; } else { $active = "0"; }
      	$edited = date('Y-m-d');
        $sname = $example->stripit($_POST['sname']);
        $fname = $example->stripit($_POST['fname']);
     	  $rating_list = array ('1' => 'Pilot / Observer', '2' => 'Student', '3' => 'Senior Student', 
          '4' => 'Controller', '5' => 'Senior Controller', '6' => 'Instructor', '7' => 'Senior Instructor', 
          '8' => 'Supervisor', '9' => 'Administration');
        //$key = array_search('green', $array);
        $rat_num = array_search($_POST['rating'], $rating_list);
        $rating = $rating_list[$rat_num];
        $id = $_POST['ID'];
        if ($_POST['act'] == "Update") {
          $error =  "SET sname = '$sname', fname = '$fname', rat_num = '$rat_num', ebbr = '$ebbr', ellx = '$ellx', info = '$info',
            visiting = '$visiting', staff = '$staff',  active = '$active', email = '".$_POST['email']."',
            vatsimid = '".$_POST['vatsimid']."', rating = '$rating' WHERE id = $id";
          //echo "rating: $rating <br>";
          //echo "$sname <br>";
          return $error;
          exit; 
        } elseif ($_POST['act'] == "Add") {
          $error = "(sname, fname, rat_num, info, vatsimid, rating, ebbr, ellx, sub_date, email, staff,
            visiting, active) VALUES ('$sname', '$fname', '$ratnum', '$info', 
            '".$_POST['vatsimid']."', '$rating', '$ebbr', '$ellx', '$edited', '".$_POST['email']."', '$staff',
            '$visiting', '$active' )";
          return $error;
          exit;          
        }
    	 } else {
    		$error = $example->create_msg();
    		return $error;
    	}      
    }
  }

  function form ($user = NULL, $action) {
    echo "<hr><b><font color=#000066 size=2 face='Verdana, Arial, Helvetica, sans-serif'>
          <div align='center'>";
         
    echo ($action==Update) ? "Update current values with:" : "Add a new record";
    echo "<br>";
  	echo ($action==Update) ? "<img src='http://online.vatsimindicators.net/" : "";
    echo empty($_POST['vatsimid']) ? $user->vatsimid : $_POST['vatsimid'];
    echo "/5417.png'><br>";
?>    
    </div></font></b>
	  <form method='post'>
	  <table width='80%' border='0' cellspacing='0' cellpadding='0' align='center'>
  		<tr>
				<td align=left valign=top>ID</td>
				<td>
				<?php echo empty($_POST['ID']) ? $user->id : $_POST['ID']; ?>
				<input type='hidden' name='ID' value=<?php echo empty($_POST['ID']) ? $user->id : $_POST['ID']; ?>></td></tr>
			<tr><td align=left>First Name</td>			
				<td><input type='text' name='fname' size='40' value='<?php echo empty($_POST['fname']) ? stripslashes($user->fname) : $_POST['fname']; ?>'></td></tr>
			<tr><td align=left>Last Name</td>			
				<td><input type='text' name='sname' size='40' value='<?php echo empty($_POST['sname']) ? stripslashes($user->sname) : $_POST['sname']; ?>'></td></tr>
			<tr><td align=left>Vatsim ID</td>			
				<td><input type='text' name='vatsimid' size='8' value='<?php echo empty($_POST['vatsimid']) ? $user->vatsimid : $_POST['vatsimid']; ?>'>
        <A HREF="http://data.vatsim.net/stats/private/list3.html?id=<? echo $user->vatsimid; ?>"
          target="_blank"><? echo $user->vatsimid; ?></A></td></tr>
			<tr><td align=left>Rating</td>			
				<td><select name='rating'>
				
<?php 
    	$rating_list = array ('1' => 'Pilot / Observer', '2' => 'Student', '3' => 'Senior Student', 
      '4' => 'Controller', '5' => 'Senior Controller', '6' => 'Instructor', '7' => 'Senior Instructor', 
      '8' => 'Supervisor', '9' => 'Administration');

      if (!$_POST['rating']) {
        $rating = $user->rating;
      } else {
        $rating = $_POST['rating'];
      } 
      
      foreach ($rating_list as $rat)
      {
        if ($rating == $rat) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$rat</option>";
      }
?>                  
				</select></td></tr>
			<tr><td align=left>EBBR</td>
        <td><select name='ebbr'>
<?php 
    	$ebbr_list = array ('1' => 'None', '2' => 'GND', '3' => 'TWR', '4' => 'APP'); 

      if (!$_POST['ebbr']) {
        $ebbr = $user->ebbr;
      } else {
        $ebbr = $_POST['ebbr'];
      } 
      
      foreach ($ebbr_list as $qual)
      {
        if ($ebbr == $qual) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$qual</option>";
      }
?>                  
				</select></td></tr>    
<?php

    	$ellx_list = array ('1' => 'None', '2' => 'TWR', '3' => 'APP'); //*************Add you extra options for the ELLX drop down here.***************

      if (!$_POST['ellx']) {
        $ellx = $user->ellx;
      } else {
        $ellx = $_POST['ellx'];
      } 
      
      foreach ($ellx_list as $qual)
      {
        if ($ellx == $qual) {
				  echo '<option selected>';
        } else {
					echo '<option>';
        }
        echo "$qual</option>";
      }
?>                  
				</select></td></tr>      			
			<tr><td align=left>E-mail</td>			
				<td><input type='text' name='email' size='50' value='<?php echo empty($_POST['email']) ? $user->email : $_POST['email']; ?>'></td></tr>
			<tr><td align=left>Active ?</td>			
				<td><input type="checkbox" name='active' value='1' <?php if ($_POST['active'] == '1' || $user->active == '1' ) { echo "CHECKED";} ?>>
        Has this controller been online as ATC the last 6 months ?</td></tr>
			<tr><td align=left>Visiting ?</td>			
			  <td><input type='checkbox' name='visiting' value='1' <?php if ($_POST['visiting'] == '1' || $user->visiting == '1' ) { echo "CHECKED";} ?>>
        Visiting Controller ?</td></tr>
			<tr><td align=left>Staff ?</td>			
				<td><input type='checkbox' name='staff' value='1' <?php if ($_POST['staff'] == '1' || $user->staff == '1' ) { echo "CHECKED";} ?>>
        Belux Staff member ?</td></tr>
			<tr><td align=left>Remark <b>(published!)</b></td>			
				<td><input type='text' name='info' size='50' value='<?php echo empty($_POST['info']) ? $user->info : $_POST['info']; ?>'></td></tr>
			<tr><td align=left>Registration Date</td>			
        <td><?php echo empty($_POST['sub_date']) ? $user->sub_date : $_POST['sub_date']; ?></td></tr>								
			<tr><td align=left>Last change</td>			
        <td><?php echo empty($_POST['last_change']) ? $user->last_change : $_POST['last_change']; ?>			
				</td>
			</tr>
				<?php				
				echo "<p align='center'><input type='submit' value='Submit' name='submit'>";
				if ($action=="Update") {
          echo "<input type='submit' value='Delete' name='submit'>";
        }
				echo "<input name='act' type='hidden' value='$action'>";
				?>
		      </form>
      </table>
<?
		}

		function listing_item ($users) {
			GLOBAL $PHP_SELF;
        echo "<TR>
        	<TH>Name</TH>
        	<TH>Vatsim ID</TH>
        	<TH>Rating</TH>
        	<TH>EBBR</TH>
		<TH>ELLX</TH>
        	<TH>Edit</TH>
        	<th>Active</th>
        	<th>Visit</th>
        	<th>Staff</th>
        </TR>";
      foreach ( $users as $user )
      {
?>
        	<TD><A HREF="mailto:<? echo $user->email; ?>"><? echo $user->fname." ".$user->sname; ?></a></TD>
        	<TD align="center"><A HREF="http://data.vatsim.net/stats/private/list3.html?id=<? echo $user->vatsimid; ?>"
              target="_blank"><? echo $user->vatsimid; ?></A></TD>
        	<TD><? echo $user->rating; ?></TD>
        	<TD><? echo $user->ebbr; ?></TD>
		<TD><? echo $user->ellx; ?></TD>
        	<TD><A HREF="<? echo $PHP_SELF."?action=edit&id=".$user->id; ?>">edit</A></TD>
        	<td align="center"><?php echo ($user->active == '1') ? "X" : ""; ?></td>
        	<td align="center"><?php echo ($user->visiting == '1') ? "X" : ""; ?></td>
        	<td align="center"><?php echo ($user->staff == '1') ? "X" : ""; ?></td>
        	<!-- TD><A HREF="<? //echo $PHP_SELF."?action=delete&id=".$user['id']; ?>">delete</A></TD -->
        	<!-- TD><A HREF="<? //echo $PHP_SELF."?action=".$endis."&id=".$data['id']."\">".$endis; ?></A></TD -->
        </TR>
<?
      }
		}

	// Start of actual program...

	$action = (isset($_GET['action'])) ? $_GET['action'] : "none";

	echo "<HTML>\n<head>\n<link rel='stylesheet' type='text/css' href='../../css/belux.css'>
        \n</head>\n<BODY class='text'>\n<CENTER>\n
	      <a href='../staff.htm'>Staff Main</a> - 
        <A HREF=".$_SERVER['PHP_SELF'].">List All</A> - 
        <A HREF=".$PHP_SELF."?action=add>Add Entry</A><P>\n<TABLE class='datatable'>\n\n";
  $member_list = "SELECT id, sname, fname, vatsimid, rating, ebbr, ellx, active, visiting, staff, email 
              FROM $table_name ORDER by fname ASC, sname ASC";
	switch ($action) {
		case "add":
			switch ($_SERVER['REQUEST_METHOD']) {
				case "POST":
				  $error = check_data($error);
				  if (substr($error, 0, 6) == "(sname") {
				    $sql = "INSERT INTO $table_name ".$error;
				    $db->query("$sql");
				    //$db->debug();
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } else {
				    echo $error;
				    $data = "";
  					form($data, 'Add');
          }
					break;
				case "GET":
				    $data = "";
  					form($data, 'Add');
					break;
			}
			//$CP->add();
			break;
		case "edit":
			//$CP->edit();
			switch ($_SERVER['REQUEST_METHOD']) {
				case "POST":
				  $error = check_data($error);
				  if (substr($error, 0, 4) == "SET ") {
				    $sql = "UPDATE $table_name ".$error;
				    $db->query("$sql");
				    //$db->debug();
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } elseif (substr($error, 0, 6) == "WHERE ") {
            $sql = "DELETE FROM $table_name ".$error;
          	$db->query("$sql");
      			$data = $db->get_results("$member_list");
      			listing_item($data);
          } else {
				    echo $error;
				    $data = "";
  					form($data, 'Update');
          }
					break;
				case "GET":
					$id = (empty($_GET['id'])) ? "" : $_GET['id'];
          $data = $db->get_row("SELECT id, sname, fname, vatsimid, rating, ebbr, ellx,
            info, last_change, active, visiting, staff, sub_date, email 
            FROM $table_name WHERE id = $id");
					form($data, 'Update');
					break;
			}
			break;
		case "delete":
			//$CP->delete();
			break;
		case "enable":
			//$CP->enable();
			break;
		case "disable":
			//$CP->disable();
			break;
		default:
			//$data = $db->get_results("SELECT id, sname, fname, vatsimid, rating FROM $table_name");
			$data = $db->get_results("$member_list");
			/*echo "<pre>";
      print_r ($users);
      echo "</pre>"; */
			listing_item($data);
	}

	echo "\n\n</TABLE>\n</CENTER>\n</BODY>\n</HTML>";
?>
```


```
roster.php 
HTML document text 
--------------------------------------------------------------------------------

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
all.clsMenuItemNS, .clsMenuItemIE{text-decoration: none; font: bold 12px Arial; color: white; cursor: hand; z-index:100}
#MainTable A:hover {color: yellow;}
</style>
<link rel="stylesheet" href="css/belux.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" class="text">
<p><font size="4" color="#004080"><br>
  <img src="../images/plane.jpg" width="20" height="15"> Belux vACC Controller 
  Roster</font></p>
<p class="text">Belux vACC Controllers who where active the last six months.
<br>(This list is updated manually)<br>
<?php 	
require_once "../bincludes/ez_sql.php";
$table_name = "members_belux";

if (isset($_GET['active'])) {
  if ($_GET['active'] == '1') {
    $list = "active";
    $where = " WHERE active = '1' ";
    echo "<a href='".$_SERVER['PHP_SELF']."?active=0' target='_self'>Show unactive controllers</a><br><br>";
  } elseif ($_GET['active'] == '0') {
    $list = "active";
    $where = " WHERE active <> '1' ";  
    echo "<a href='".$_SERVER['PHP_SELF']."?active=1' target='_self'>Show active controllers</a><br><br>";
  }
} else {
    $list = "active";
    $where = " WHERE active = '1' ";
    echo "<a href='".$_SERVER['PHP_SELF']."?active=0' target='_self'>Show unactive controllers</a><br><br>";
}

$sql = "SELECT fname, sname, vatsimid, rat_num, rating, ebbr, ellx, info, staff, visiting, 
  active FROM $table_name".$where."ORDER BY fname ASC, sname ASC";
  
if ($data = $db->get_results("$sql")) {
?>
	 <table class="datatable" >
  		<tr>
    		<th ><b>Name</b></th>
    		<th align=center><b>Rating</b></th>
    		<th align=center><b>EBBR</b></th>
		<th align=center><b>ELLX</b></th>
    		<th align=center><b>Vatsim ID</b></th>
    		<th ><b>Remarks</b></th>
    		<th><b>Guest</b></th>
    		<th><b>Staff</b></th>
		  </tr>
<?
  foreach ( $data as $member )
  {
?>
	<tr>
	<td align=left><? echo "$member->fname $member->sname"; ?></td>
	<td align=center><? echo $member->rating; ?></td>
	<td align=left><?php echo $member->ebbr; ?></td>
	<td align=left><?php echo $member->ellx; ?></td>
	<td align=center><a href="http://data.vatsim.net/stats/private/list3.html?id=<?php echo $member->vatsimid; ?>"  target="_blank"><?php echo $member->vatsimid; ?></a></td>
	<td align=left><?php echo $member->info; ?></td>
	<td align=center><?php if ($member->visiting == '1') { echo "X"; } ?></td>
	<td align=center><?php if ($member->staff == '1') { echo "X" ;} ?></td>
	</tr>
	
	<?php


  }

  $date = $db->get_var("SELECT last_change FROM $table_name ORDER BY last_change DESC") ;
  $date = substr($date, 8, 2)."-".substr($date, 5, 3).substr($date, 0, 4);
  
	?>
	</table> <?

} else {

	echo "Sorry, no records were found!";	

}
?>

<hr>
<span class="updated">Last update: 
<!-- #BeginDate format:Am1 -->
<?php echo empty($date) ? "August 22, 2007" : $date; ?><!-- #EndDate -->
</span> 
</body>
</html>
```


----------



## Guest (Oct 16, 2008)

bump


----------



## Guest (Oct 20, 2008)

hello? Anyone please ....


----------



## Guest (Oct 25, 2008)

> The bad news:
> 1) I don't see the column ELLX when I just take a look at the roster (without being logged in as admin), though this might be related the the following:
> 2) The ELLX has no dropdown menu, the options are just there as text (see attachment!)


Ok, all issues have been resulted ...

1) There was an other php in the website ... which I edited just like the roster.php .. WORKED
2) I found the fault ...can you ?


> [/TD][/TR]
> [TR][TD]EBBR[/TD]
> [TD]
> <?php
> ...


OK let's give a hint:



> [/TD][/TR]
> [TR][TD]EBBR[/TD]
> [TD]<?php
> $ebbr_list = array ('1' => 'None', '2' => 'GND', '3' => 'TWR', '4' => 'APP');
> ...


So basically 2 lines were missing for ELLx, you see why I hate PHP ... 

Anyway DMcCabe .. once more thx ... I owe you one ....
*And once more problem resolved thanks to Techguy Forums !!! Keep us the good work guys !*


----------

