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

2
  • 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 Commented Apr 26, 2017 at 14:29
  • You are expected to try to write the code yourself. After doing more research 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. Read How to Ask a good question. Be sure to take the tour and read this. Commented Apr 26, 2017 at 14:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.