Hello everyone, you must write to the array of the obtained value from the database, if it satisfies the condition. Here is the code, but does not give the value. Thanks for the help, please do not throw stones.

$ID=1; $ans1 = Array(); for ($i=1; $i<21; $i++){ if ($norm_getting[$i] ==1){ $query = "SELECT * from sfer_name LEFT JOIN calc on sfer_name.id_sfer = calc.id_sfer where calc.ID = $ID and calc.id_sfer = $i and calc.norm_getting = $norm_getting[$i]"; // получаем значения из таблицы с полученными ответами $sql = mysql_query($query,$link)or die(mysql_error()); $row = mysql_fetch_array($sql); $ans1[]=$row['sfer_name']; } } 

    1 answer 1

    Take advantage. This is my example, substitute your request and data!

      $query = $this->db->query(" SELECT *, DATE_FORMAT(pd.birthday,'%d.%m.%Y') as birthday_edit FROM phone_directory pd WHERE pd.phone_category = '$category' AND pd.fio LIKE '%$search%'"); $count=0; if ($query->num_rows() > 0) { foreach ($query->result_array() as $row[$count]){ $count++; } 

    The result will be in the $ row [$ count] array.

    In your example, just look at the request to be processed, because there are suspicions that there is an error in the syntax. Or rather, calc.ID = $ ID should be written as calc.ID = '$ ID'. The variable must be in single brackets.