<?php foreach ($imageData as $image) { ?> <tr align = center> <td> <img src = "<?php echo getImageById($image['id']); ?> "> </td> <td><?php echo $image['description']; ?> </td> <td><?php echo getImageById($image['id']); ?> </td> <td><button type = "submit" name = "deleteImage" class = "btn btn-danger" onclick = "deleteImage(<?php echo $image['id']; ?> );">Удалить</button></td> </tr> <?php } ?> </table> <?php } else { ?>
function deleteImage($imageId) { $link = getDBConnection(); if (mysqli_select_db($link, getDBName())) { $imageId = intval($imageId); mysqli_query($link, "DELETE FROM images WHERE id = {$imageId}"); removeDir(getImageById($imageId)); } }