I made a site for displaying images on a local server (OpenServer). I open the main page with all the images, then open the page, with a full description of the image, and the image is not displayed, and the page code in the src argument is null. Then the same image stops opening on the main page. The code of the main page and the page with the description of the image will be attached below.
Code for displaying images on the main page
$sql_qestion = "SELECT * FROM Mangas WHERE `src` != '' LIMIT 20 OFFSET 0; "; $kol = 9; //количество записей для вывода $art = ($page * $kol) - $kol; // определяем, с какой записи нам выводить $result = mysqli_query($link,"SELECT * FROM `Mangas` WHERE `src` != '' ORDER BY id DESC LIMIT $art,$kol"); $res=mysqli_query($link,"SELECT * FROM Mangas WHERE `src` != ''"); $q = mysqli_query($link,$sql_qestion); $total= mysqli_num_rows($res); $str_pag = ceil($total / $kol); $manga=mysqli_fetch_array($result); do{ $href="article.php?id=".$manga[id]; ?> <div class="work"> <a href="<?php echo $href ?>"> <?php echo "<img src= '"; if ($manga[src]!=""){ echo $manga[unical_id]; } else { echo "img/no_img.webp"; }; echo " ' class='media' alt='' ".'/>'; ?> <div class="content_row" > <h4><?php echo $manga[title] ?></h4> </div> </a> </div> <?php }while ($manga = mysqli_fetch_array($result)); ?>
Page code for image output and description
<div class="article_container"> <div><img class="img_s" src="<?php echo $sql[unical_id] ?>"></div> <div><h1 class="title_of_manga"><?php echo $sql["title"] ?></h1></div> <div class="tags"><p ><?php echo $sql[tags] ?></p></div> </div> <a class="sun-flower-button" href='manga_reder.php?id=<?php echo $sql[id] ?>'><div> Watch manga</div> </a>
do while
, usewhile
. You have a cycle of data output on the screen. So doing is not good. Also in the cycleif ($manga[src]!=""){
, It can be replaced withif ($manga[src]) {
, besides, the condition is redundant since sql query already cuts such a sample. Even in the code you have a lot of errors, but the comment does not fit. Well, answering your question, not knowing what$sql
and what it is equal to you, it is not possible to answer your question. Arrange byvar_dump($переменная)
codevar_dump($переменная)
and see where the data is not what it should be. - ArchDemon