Answer the question
In order to leave comments, you need to log in
Output from database to array
There is a table with records, it is necessary to display data from it only from one column and present it as an array from
$r=$mysqli->query("SELECT company_URL_name FROM company");
//в массив вида
$arr=array('AUDI', 'BMW', 'NISSAN', 'TOYOTA');
//чтобы работала проверка вида
if((in_array($_GET['n1'], $arr))){
}
$r=$mysqli->query("SELECT company_URL_name FROM company");
$urls=array();
while($row=mysqli_fetch_array($r)){
$urls[] = $row['company_URL_name'];
}
if((in_array($_GET['n1'], $urls))){
echo $urls;
}
else{
echo 'Введеня вами страница не существует';
}
Answer the question
In order to leave comments, you need to log in
Use array_search
$key=array_search($_GET['n1'], $urls);
if($key!==false){
echo $urls[$key];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question