public function GetSpecifiedData($tableName, $atributeName, $value)
{
$sqlConntect = new mysqli(SERVER, USERNAME, PASSWORD, DATABASE);
if(!mysqli_connect_errno())
{
$atributes = null;
foreach ($atributeName as $atributeTemp)
$atributes .= sprintf("%s,", $atributeTemp);
$atributes = substr($atributes, 0, -1);
$values = null;
if($value != null)
{
foreach ($value as $valueTemp)
$values .= sprintf("'%s', ", $valueTemp);
$values = substr($values, 0, -2);
}
$sqlCommand = null;
if($atributeName != null && $value != null)
$sqlCommand = sprintf("SELECT %s FROM %s WHERE %s", $atributes, $tableName, $values);
if($atributeName == null && $value != null)
$sqlCommand = sprintf("SELECT * FROM %s WHERE %s", $tableName, $values);
if($atributeName != null && $value == null)
$sqlCommand = sprintf("SELECT %s FROM %s", $atributes, $tableName);
if($atributeName == null && $value == null)
$sqlCommand = sprintf("SELECT * FROM %s", $tableName);
if($sqlCommand != null)
{
$output = array();
if($sqlResult = $sqlConntect->query($sqlCommand))
{
while ($sqlRow = $sqlResult->fetch_row()) {
$output[] = $sqlRow;
}
}
return $output;
}
}
else
echo sprintf("Connection to Database Faild. Message: %s", mysqli_connect_error());
return null;
}