There is a table tbl_uploads where the paths to the images (x-rays) are stored. There is a priem table where patient records are stored. It is necessary to do so if there is a X-ray picture in the tbl_uploads table that relates to this technique, then output the link. And if not, then just the text that there is no X-ray. I do this so first I push the sessid field into the array (the field where the reception number is stored) from the tbl_uploads table
$rentresult = mysqli_query($con, "SELECT sessid FROM tbl_uploads WHERE size = $id ;" ); $rent = array(); while( $rowr = mysqli_fetch_assoc($rentresult ) ) { $rent[] = $rowr['sessid'] ; Then, with the second query, when I pull out all the records from the priem table, I check if there is a session number in the $rent[] array and if not, then the text is not X-ray and if there is that link
$result2 = mysqli_query($con,"SELECT * FROM priem WHERE card_id=$id") or die("<p>Не удается выбрать запись из базы данных</p>". mysqli_error($con)); ?><?php while($row2 = mysqli_fetch_assoc($result2 )) { $has_xray='Нет рентгена'; if (in_array($row2['sessid'] , $rent)) { $has_xray='Есть рентген'; } And finally, this way I display
<td> <?php echo $has_xray ; ?> </td> The trouble is that even when there is an x-ray in the table, it still shows that there is no x-ray. Where do I make a mistake? Can a condition, can I check it wrong?
size = $id? Judging by the name of the column in size, the size of something must lie (apparently the file) and what the ratio is the size in no one id as it is not clear ... - Mikevar_dump($rent);- Is everything normal there? - Ivan Bolnikh