0

Hello guys i am doing a archived page and i have added option to restore all but after that every newly deleted product doesn't show up
here's the script

//php to get update data upon click of button
<?php

if (isset($_GET['all'])) {
        $allSql = "UPDATE products SET deleted = 0 WHERE deleted = 1";
        $allresult = $db->query($allSql);
        header('Location: products.php');
    }
?>
<?php

//restore button
 if($archived['deleted'] == 1){ ?>
<a href="archived.php?all" class="btn btn-success pull-left" id="restore-all-btn">Restore All</a>
 <?php 
  }else{
    echo "You have no archived products to show.";
}

?>

the products are updated but even if deleted =1 it doesn't show up on the page

2
Contributors
2
Replies
14
Views
1 Year
Discussion Span
Last Post by sahilmohile15
0

db is really updated

<?php 
    require_once $_SERVER['DOCUMENT_ROOT'].'/Online Store/core/init.php';
    include 'includes/head.php';
    include 'includes/navigation.php';

    $sql = "SELECT * FROM products WHERE deleted = 1";
    $aresults = $db->query($sql);
    $archived = mysqli_fetch_assoc($aresults);
    if (isset($_GET['restore'])) {
        $restore_id = sanitize($_GET['restore']);
        $sql = "UPDATE products SET deleted = 0 WHERE id = '$restore_id'";
        $aresult = $db->query($sql);
        header('Location: products.php');
    }

    if (isset($_GET['all'])) {
        $allSql = "UPDATE products SET deleted = 0 WHERE deleted = 1";
        $allresult = $db->query($allSql);
        header('Location: products.php');
    }

?>

<h2 class="text-center">Archived</h2><hr />


<?php

 if($archived['deleted'] == 1){ ?>
<a href="archived.php?all" class="btn btn-success pull-left" id="restore-all-btn">Restore All</a>
 <?php 
  }else{
    echo "You have no archived products to show.";
}

?>

<table class="table table-bordered table-condensed">
    <thead>
        <th></th>
        <th>Products</th>
        <th>Price</th>
        <th>Categories</th>
    </thead>
    <tbody>
        <?php while($archived = mysqli_fetch_assoc($aresults)) : 
            $childID = $archived['categories'];
            $catSql = "SELECT * FROM categories WHERE id = '$childID'";
            $result = $db->query($catSql);
            $child = mysqli_fetch_assoc($result);
            $parentID = $child['parent'];
            $pSql = "SELECT * FROM categories WHERE id = '$parentID'";
            $presult = $db->query($pSql);
            $parent = mysqli_fetch_assoc($presult);
            $category = $parent['category'].'~'.$child['category'];
            ?>
            <tr>
        <tr>

            <td>
                <a href="archived.php?restore=<?= $archived['id']?>"><span class="glyphicon glyphicon-repeat"></span></a>
            </td>
            <td><?= $archived['title']; ?></td>
            <td><?= $archived['price']; ?></td>
            <td><?= $category; ?></td>
        </tr>
        <?php endwhile; ?>
    </tbody>
</table>




<?php include 'includes/footer.php'; ?>

this is the page few valus show but few doesn't show even if database is updated

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.