<?php

function create_select_list($ip) {
  $fd=fopen("user_name", "r");  
  $select1 = "<select name=\"lookupname\" onchange=\"userselected(this);\" size=40>";
  $select2 = "<select name=\"ip\" size=40  >";
  $count = 0;

  while(!feof($fd)){
    $count++;
    $str=fgets($fd,1000);
    $tmp = split('[ ]',$str);
    $select1 .= "<option value=\"$tmp[0]\">($count) $tmp[0]</option>";
    if($count==1 && $ip==''){
      $select2 .= "<option value=\"$tmp[2]:$tmp[3]\" selected=\"selected\">($count) $tmp[1]:$tmp[3]</option>";
    }else if(strcmp($ip,trim("$tmp[2]:$tmp[3]"))==0){
      $select2 .= "<option value=\"$tmp[2]:$tmp[3]\" selected=\"selected\">($count) $tmp[1]:$tmp[3]</option>";
    }else {
      $select2 .= "<option value=\"$tmp[2]:$tmp[3]\">($count) $tmp[1]:$tmp[3]</option>";
    }
  }
  $select1 .= "</select>";
  $select2 .= "</select>";
  
  echo("    <tr>
      <td> <b>User name ($count)</b> </td>
      <td> <b>Host name ($count) </b></td>
    </tr>");

  //echo("<tr><th>count= $count</th></tr>");
  echo("<tr><th>");
  echo($select1);
  echo("</th>");
  //echo("&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp");
  echo("<th>");
  echo($select2);
  echo("</th></tr>");
  //echo("&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp");
  
}
?>