Answer the question
In order to leave comments, you need to log in
How to check for the existence of a record in the database in 1C Bitrix?
Greetings. Guys, tell me why the text from the $disp variable is displayed immediately, but in fact the check works. The same design but works in a normal document. I use this code in Bitrix.
<?
$pol = $_POST['course'];
$gr = $_POST['gr'];
$disp = "В этом году для Вашего года рождения нет диспансеризации.";
$my = $DB->Query("SELECT * FROM b_dispp_2018 WHERE gr='$gr' && pol='$pol'");
$result = $my->Fetch();
if ($result) {
echo '<h2 style="color:green">' . $result['inf'] . '</h2>';
}
else
{
echo $disp;
}
?>
Answer the question
In order to leave comments, you need to log in
1) Read about sql injections. Example
2) If I were you, I would avoid using $DB->Query for queries. It's better to use D7 ORM instead . You describe the table with a class, and then use the data selections via getList or Query if you need a specific query.
Well, as already said, you need to check something more specific. From your description, it is not at all clear what you are trying to do.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question