Guys, please tell me why my pictures are not displayed in the specified px, and on the site only the original is displayed. Che wrong in this code?

if ($row["imagesad"] != "" && file_exists("ph_main/" . $row["imagesad"])) { $img_path = 'ph_main/' . $row["imagesad"]; $max_width = 114; $max_height = 105; list($width, $height) = getimagesize($img_path); $ratioh = $max_height / $height; $ratiow = $max_width / $width; $ratio = min($ratioh, $ratiow); $width = intval($ratio * $width); $height = intval($ratio * $height); } else { $img_path = "images/no-image.png"; $width = 110; $height = 200; } echo ' <li> <div class="block-images-grid"> <img src="ph_main/' . $row[" imagesad"] . '"> </div> <p class="style-title-grid"><a href="">' . $row["title"] . '</a></p> <ul class="reviews-and-counts-grid"> <li><img src="images/eye-icon.png"> <p>0</p></li> <li><img src="images/comment-icon.png"> <p>0</p></li> </ul> <p class="style-price-grid"><strong></strong></p> <div class="mini-features"> <p>Город:</p> <p>Дата:</p> </div> </li> '; } 
  • And it is impossible to use the calculated variables $img_path , $width and $height in code? - Visman
  • Could you set an example? I will be very grateful :) - Eugene

1 answer 1

That's right, @Visman said. You calculate the data for the image, but do not use it.
If the code was written by you, I do not understand what difficulties you have when using it.

Here is your example with the substituted variables:

 echo ' <li> <div class="block-images-grid"> <img src="' . $img_path . '" style="width:' . $width . 'px;height:' . $height. 'px;"> </div> <p class="style-title-grid"><a href="">' . $row["title"] . '</a></p> <ul class="reviews-and-counts-grid"> <li><img src="images/eye-icon.png"> <p>0</p></li> <li><img src="images/comment-icon.png"> <p>0</p></li> </ul> <p class="style-price-grid"><strong></strong></p> <div class="mini-features"> <p>Город:</p> <p>Дата:</p> </div> </li> '; 
  • Thank you very much. No, I did not write the code, I only redo it, I watched the video, so there he wrote it. Thank you again! - Eugene