0

i have a table which is populated of database data.

   <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Product Name</th>
                                    <th>Brand</th>
                                    <th>Category</th>
                                    <th>Featured</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach($products as $product){ ?>
                                <tr>
                                    <td><?= $product->name; ?></td>
                                    <?php $brand->select("brand","products_brands")->where("id")->build();
                                    $pbrand = $brand->execute(array($product->brand))->fetch();?>
                                    <td><?= $pbrand->brand; ?></td>

                                    <?php $category->select("category,parent","products_categories")->where("id")->build();
                                    $procatChild = $category->execute(array($product->category))->fetch(); 
                                    $category->select("category","products_categories")->where("id")->build();
                                    $procatParent = $category->execute(array($procatChild->parent))->fetch(); ?>
                                    <td><?= $procatParent->category. " - " .$procatChild->category; ?></td>
                                    <td>
                                        <a id="afeat" href="products.php?product_id=<?= $product->id;?>&featured=<?= $product->featured;?>" class="btn btn-default btn-sm">
                                            <span class="<?= ($product->featured == 0) ? "fa fa-times-circle" : "fa fa-check-circle"; ?>"></span>
                                        </a>
                                    </td>
                                </tr>
                                <?php } ?>
                            </tbody>
                        </table>

now i want to update the featured field by clicking the a tag, but i didnt know how to pass the url parameters to ajax data to send it to php update script.I have been looking for the same problem but i didnt find concrete solutions. Thanks in advance guys

  • 1
    Do you know anything about AJAX at all (I'm asking seriously) - Did you try anything yet, and did you use pure JS or jQuery? Please share what you tried so far, and if you're using specific library then add it to the tags of your question – Alon Eitan Apr 26 '17 at 14:29
  • You are expected to try to **write the code yourself**. After [**doing more research**](https://meta.stackoverflow.com/q/261592/1011527) if you have a problem **post what you've tried** with a **clear explanation of what isn't working** and provide [a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Read [How to Ask](http://stackoverflow.com/help/how-to-ask) a good question. Be sure to [take the tour](http://stackoverflow.com/tour) and read [this](https://meta.stackoverflow.com/q/347937/1011527). – Jay Blanchard Apr 26 '17 at 14:46

0 Answers0