<?php
if (isset($_POST['deletephoto'.$photoid])) {
$photoid1 = $mysqli->real_escape_string(stripslashes($_REQUEST['photoid1']));
$mysqli->query("DELETE FROM extras WHERE type=0 AND insert_id='$photoid1'");
unlink("./".$filepath."photos/".$photoid1.".jpg");
$mysqli->query("ALTER TABLE extras AUTO_INCREMENT = 1");
}?>

<?php if (file_exists("./".$filepath."photos/".$photoid.".jpg")) { ?>

<li id="listarray_<?php echo $photoid ?>" class="divphoto1" title="<?php echo $adminreorder ?> photos">
<div class="divphoto">
<a id="thumb<?php echo $photoid ?>" href="<?php echo $filepath ?>photos/<?php echo $photoid ?>.jpg" onclick="return hs.expand(this)"><img src="../includes/image.php?image=<?php echo $filepath ?>photos/<?php echo $photoid ?>.jpg&amp;nwidth=50" class="pphoto" alt="<?php echo $pname ?>" title="<?php echo $ppriority ?> <?php echo $pname ?>"></a> 
</div>

<div class="margtop5">

<div class="floatleft">
<a href="edit-photo.php?id=<?php echo $photoid?>" title="<?php echo $adminedit ?>" class="buttonicon color1"><span class="icon fa-edit"></span></a>
</div>

<div class="floatright">
<form name="forma" method="post">
<input type="hidden" name="photoid1" value="<?php echo $photoid ?>">
<input type="hidden" name="deletephoto<?php echo $photoid ?>" value="submit">
<button type="submit" name="deletephoto<?php echo $photoid ?>" title="<?php echo $admindelete ?>" class="buttonicon color1"><span class="icon fa-trash-o"></span></button>
</form>
</div>

</div>

</li>

<?php } ?>