我正在尝试从具有多个ID的同一Mysql列中获取数据,并将每个ID分配给一个变量。
我的桌子就是这样
NaN
php代码是
var operator = document.getElementById(ButtonIds).value;
var Quantity = document.getElementById(QuantityIds).value;
GetQuantity = Number(Quantity);
testing = parseInt(GetQuantity);
if(operator == '+') {
testing = testing + 1;
}
else {
testing = testing - 1;
}
alert(testing);
document.getElementById(QuantityIds).innerHTML=testing;
答案 0 :(得分:0)
大多数情况下的 id 列为整数,
然后从下面的行中删除单引号
更改此
$sql = "SELECT credit FROM dailycredits Where id IN ('1','2','3')";
至
$sql = "SELECT credit FROM dailycredits Where id IN (1, 2, 3)";
注意:单引号已从 IN
中删除尝试一下...
$sql = "SELECT credit FROM dailycredits Where id IN (1,2,3)";
$result = $connect->query($sql);
$rows = []; //empty array.
while ($row = mysql_fetch_array($result)){
$rows[] = $row; //assigning credit to array.
}
print_r($rows);
或者您现在可以像$ rows [0],$ rows [2]这样访问。
由于mysql_ 在php 5.5.0中已弃用,我强烈建议您不要使用mysql _ ,而应使用 mysqli _ * 。