84 lines
1.5 KiB
PHP
84 lines
1.5 KiB
PHP
<?php
|
|
|
|
Class Dropdown
|
|
{
|
|
|
|
private $host = 'localhost';
|
|
private $username = 'u00wiumd4xnrd';
|
|
private $password = 'ukowysga7w5x';
|
|
private $dbname = 'dbcov4clvrmrzn';
|
|
private $connection;
|
|
|
|
//establish connection
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
try
|
|
{
|
|
$this->connection = new mysqli($this->host, $this->username, $this->password, $this->dbname);
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
echo "Connection error " . $e->getMessage();
|
|
}
|
|
}
|
|
|
|
|
|
//fetch all country records from database
|
|
public function fetchCountry()
|
|
{
|
|
$data = null;
|
|
|
|
$query = "SELECT * FROM article_type ORDER BY article_type.name_articletype";
|
|
|
|
if ($sql = $this->connection->query($query))
|
|
{
|
|
while ($rows = mysqli_fetch_assoc($sql))
|
|
{
|
|
$data[] = $rows;
|
|
}
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
//fetch model records from database depend upon country id
|
|
public function fetchModel($idarticletype)
|
|
{
|
|
$data = null;
|
|
|
|
$query = "SELECT * FROM modelarticle WHERE idarticletype='".$idarticletype."' ";
|
|
|
|
if ($sql = $this->connection->query($query))
|
|
{
|
|
while ($rows = mysqli_fetch_assoc($sql))
|
|
{
|
|
$data[] = $rows;
|
|
}
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
//fetch Charact records from database depend on article type
|
|
public function fetchCharact($idarticletype)
|
|
{
|
|
$data = null;
|
|
|
|
$query = "SELECT * FROM article_characteristic WHERE idarticletype='".$idarticletype."' ";
|
|
|
|
if ($sql = $this->connection->query($query))
|
|
{
|
|
while ($rows = mysqli_fetch_assoc($sql))
|
|
{
|
|
$data[] = $rows;
|
|
}
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|