I have this piece of code from which I want to get a single array containing all the values.
$sql = "SELECT * FROM interest where interest='".$interest."' and userid!='".$myuserid."'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $userid = $row["userid"]; if($searchtype == 'both') { $sql2 = "SELECT * FROM register where id='".$userid."' and discover = 'on' and id!='".$myuserid."'"; $result2 = mysqli_query($conn, $sql2); if (mysqli_num_rows($result2) > 0) { while($row2 = mysqli_fetch_assoc($result2)) { echo "<pre>"; print_r($row2); echo "</pre>"; } } } } }
The o / r that I get is something like this
Array ( [id] => 1 [email] => A1 [username] =>B1 [password] => C1 [gender] => C1 ) Array ( [id] => 2 [email] => A2 [username] => B2 [password] => C2 [gender] => D2 ) Array ( [id] => 3 [email] => A3 [username] => B3 [password] => C3 [gender] => D3 )
But I want to get all the data in one array like this
Array ( [0] => Array ( [id] => 1 [email] => A1 [username] =>B1 [password] => C1 [gender] => C1 ) [1] => Array ( [id] => 2 [email] => A2 [username] => B2 [password] => C2 [gender] => D2 ) [2] => Array ( [id] => 3 [email] => A3 [username] => B3 [password] => C3 [gender] => D3 ) }
can anyone tell how i can do this
source share