Re: Delete form from <select>

27 views
Skip to first unread message
Message has been deleted

de...@roo.com.br

unread,
May 27, 2021, 12:33:30 AM5/27/21
to redbeanphp
try:
var_dump( $_POST );

Em segunda-feira, 24 de maio de 2021 às 07:09:45 UTC-3, darzema...@gmail.com escreveu:
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>
Reply all
Reply to author
Forward
0 new messages