I have what I thought would be a simple process updating old "mysql" code to "mysqli." In a number of places there was code that iterated through a multi-dimensional array to get the values. I'm trying to make a similar loop and use either mysqli_fetch_array or mysqli_fetch_all and am just banging my head against a wall. Either the process fails (hang) or else it doesn't return any values. I have looked all over the web and found various examples, none of which have quite worked...often they're not for procedural method (https://stackoverflow.com/questions/12026979/how-do-iterate-the-result-of-mysqli-fetch-array).
I currently have:
$query2 = "SELECT * FROM mp WHERE email='$email'";
//connect to database
require("../dbinfo.php");
$con = mysqli_connect($host,$username,$password,$database);
$result2=@mysqli_query($con, $query2);
$array = mysqli_fetch_array($result2, MYSQLI_BOTH);
@mysqli_close($con); //question...does this need to come later, after num_rows?
$num2=0;
$num2=@mysqli_num_rows($result2);
$a=0;
while ($a < $num2)
{
//cycle through to get info...this comes up blank, when it should have 3 sets of values.
$var1=$array[$a]["column"];
$var2=$array[$a]["id"];
echo "Column: ".$var1." and ID: ".$var2;
}
I've seen a lot of answers that essentially say "Use PDO" or "why use procedural? Object oriented is the way to go" but I'm really not looking to do a different style. It would be great to just know what's causing the above to fail. I can't be too far off, right? Thank you in advance for the help!