2
我想为我的每个行(tr)从我的数据库生成一个行值。所以我们说,我已经产生如下表:你可以设置表中某一行的值吗?
while ($row = $database->fetch_array($result))
{
$i=1-$i;
$class = "row".$i;
echo "<tr class='{$class} productId' id='{$row['productId']}'>
<td > ". $row['category']."</td>
<td >" . $row['productNo']. "</td>
<td>" . $row['productName']. "</td>
<td class='edit'>" . intval($row['quantity']). "</td>
<td>" . $row['sfLf']. "</td>
<td>". $row['cost']. "</td>
<td>". $row['total']."</td>
</tr>";
}
在这里,我试图通过id属性来传递的ProductID值,但不幸的是,ID停留时,我在下面的脚本尝试检索所有行相同:
$(".productId").click(function() {
$.ajax({
type: "POST",
url: "populateInventory.php",
data: "productId="+$(".productId").attr('id'),
success: function(msg){
$("#invHistoryTable").html(msg);
}
});
如何使用上述ajax命令将正确的productId值传递给我的php页面? 谢谢
即便我做了以下我现在还无法得到正确的结果:数据:{产品编号:$( “productId参数”)ATTR( '身份证')} – RazorHead 2013-02-24 00:52:16