我有一个填充了数据库数据的表。
<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>
现在我想通过单击a标签来更新特色字段,但我不知道如何将url参数传递给ajax数据以将其发送到php更新脚本。我一直在寻找相同的问题,但我没有找到具体方案。在此先感谢你们