php - MySQLi multiple prepared statements using previous fetched $variable -
$stmt = $mysqli->prepare("select id,name,master,level,exp player.guild order exp desc"); $stmt->execute(); $stmt->bind_result($id, $name, $master, $level, $exp); $stmt->fetch(); $guildnum = $stmt->num_rows; $stmt->store_result(); $stmt->close(); $stmt2 = $mysqli->prepare("select id,login account.account id=?"); $stmt2->bind_param("i", $master); $stmt2->execute(); $stmt2->bind_result($boss_id, $boss_name); $stmt2->store_result(); $stmt2->close(); $stmt3 = $mysqli->prepare("select empire player.player_index id=?"); $stmt3->bind_param("i", $boss_id); $stmt3->execute(); $stmt3->bind_result($empire); $stmt3->store_result(); $stmt3->close();
$stm2 , $stm3 not returning result..
//explaining code
$stm fetch details , store them $variables
$stm2 uses variable $master fetch "id" , "login" , store them other variables
$stm3 uses $boss_id (stored $stm2) fetch , set variable $empire
//explaining code
can me please?
regards.
so if correct, need fetch values (bind_result)
$stmt = $mysqli->prepare("select id,name,master,level,exp player.guild order exp desc"); $stmt->execute(); $stmt->bind_result($id, $name, $master, $level, $exp); $stmt->fetch(); //fetch values $guildnum = $stmt->num_rows; $stmt->store_result(); $stmt->close(); $stmt2 = $mysqli->prepare("select id,login account.account id=?"); $stmt2->bind_param("i", $master); $stmt2->execute(); $stmt2->bind_result($boss_id, $boss_name); $stmt2->fetch(); //fetch values $stmt2->close(); $stmt3 = $mysqli->prepare("select empire player.player_index id=?"); $stmt3->bind_param("i", $boss_id); $stmt3->execute(); $stmt3->bind_result($empire); $stmt3->fetch(); //fetch values $stmt3->close();
Comments
Post a Comment