How to delete exactly the selected category from <select><option> there are categories 1,2,3
when selecting category 3 or 2 deletes the first one.
<?php
include 'config/config.php';
$categorys = R::findAll('category');
foreach ($categorys as $id){
$re_count[] = $id;
}
if (isset($data['del'])) {
$delete = R::FindOne('category');
R::trash($delete);
unlink('pages/'.$delete->page.'.php');
echo "<script>self.location='test2.php';</script>";
}
?>
<form method="POST">
<select name="id" style="width:250;">
<?php for ($n = 0; $n < count($id); $n++): ?>
<option value="<?=$id[$n]->id;?>" ><?php echo $re_count[$n]->category_name; ?></option>
<?php endfor; ?>
</select>
<p><input type="submit" name="del" value="Удалить"></p>
</form>