bmspage/includes/classes/select.class.php

70 lines
2.3 KiB
PHP
Raw Normal View History

2015-03-30 23:45:30 -04:00
<?php
class SelectList
{
protected $conn;
public function __construct()
{
$this->DbConnect();
}
protected function DbConnect()
{
include "/home/srv/html/bms/includes/db_config.php";
$this->conn = mysql_connect($servername,$username,$password) OR die("Unable to connect to the database");
mysql_select_db($db,$this->conn) OR die("can not select the database $db");
return TRUE;
}
public function ShowDCs()
{
$sql = "SELECT * FROM datacenters ORDER BY dc_name";
$res = mysql_query($sql,$this->conn);
$datacenter = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$datacenter .= '<option value="' . $row['dc_id'] . '">' . $row['dc_name'] . '</option>';
}
return $datacenter;
}
public function ShowUnitType()
{
$sql = "SELECT * FROM unittypes ORDER BY utype_name";
$res = mysql_query($sql,$this->conn);
$unittype = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$unittype .= '<option value="' . $row['utype_id'] . '">' . $row['utype_name'] . '</option>';
}
return $unittype;
}
public function ShowUnits()
{
$sql = "SELECT * FROM units WHERE utype_id=$_POST[utype_id] AND dc_id=$_POST[dc_id] ORDER BY unit_name";
$res = mysql_query($sql,$this->conn);
$unit = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$unit .= '<option value="' . $row['unit_id'] . '">' . $row['unit_name'] . '</option>';
}
return $unit;
}
public function ShowAlerts()
{
$sql = "SELECT * FROM alerts WHERE utype_id=$_POST[utype_id] ORDER BY alert_name";
$res = mysql_query($sql,$this->conn);
$alert = '<option value="0">choose...</option>';
while($row = mysql_fetch_array($res))
{
$alert .= '<option value="' . $row['alert_id'] . '">' . $row['alert_name'] . '</option>';
}
return $alert;
}
}
$opt = new SelectList();
?>