我用select stmt运行php文件。如果reslut == 1:运行第二个stmt。如果不是 - 不要运行它。问题是第二个stmt只有在我设置时运行:if(mysqli_num_rows($ statement)== 0:但是 - 第一个stmt结果不是0 ...即时启用登录到我的android应用程序 - 意味着找到行... )
这是我的代码:
<?php
$con=mysqli_connect("localhost","xxxxx","xxxxxx","xxxxxx");
$groupname= $_POST["groupname"];
$grouppassword= $_POST["grouppassword"];
$loggedInUser= $_POST["loggedInUser"];
$statement = mysqli_prepare($con, "SELECT * FROM MGroup WHERE group_name= ? AND group_password = ?");
mysqli_stmt_bind_param($statement, "ss", $groupname, $grouppassword);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $groupID, $groupname, $grouppassword, $group_owner);
$group= array();
while(mysqli_stmt_fetch($statement)){
$group["groupname"]=$groupname;
$group["grouppassword"]=$grouppassword;
$group["group_owner"]=$group_owner;
}
echo json_encode($group);
//update logged-in user with his current group - its is not necessary the group owner
if(mysqli_num_rows($statement) == 1) {
$statement= mysqli_prepare($con,"UPDATE User SET group_code = (SELECT group_id FROM MGroup WHERE group_name = ? ) WHERE username= ?");
mysqli_stmt_bind_param($statement,"ss",$groupname,$loggedInUser);
mysqli_stmt_execute($statement);
}
mysqli_stmt_close($statement);
mysqli_close($con);
?>
答案 0 :(得分:0)
另一个可能的解决方案是只计算$ group数组。有点简单但它也可以。
> Mean
[1] 3.333333 4.666667 6.000000 5.000000 7.000000 NaN 5.000000 4.000000 5.000000