looping through mysqli stored proc results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sauco1
Forum Newbie
Posts: 1
Joined: Sun Oct 17, 2010 1:38 pm

looping through mysqli stored proc results

Post by sauco1 »

I don't know why I can't figure this out, have spent 5+ hours on this, I'm a newb to php but how hard can this possibly be?? Going to puke. :banghead:

All I want to do is run a stored stored procedure that returns a result set and then loop through the results.

I've tried hundreds of different things. I realize the below code is not even close to correct, it's just meant to illustrate what I'm trying to do. As I have it now, it runs up to the while statement and crashes. I realize there's no fetch_array for what I'm trying to do but that's the functionality I'm trying to get (I had it working with mysql_query and fetch_array before).

Please help! If I could see some mysqli code that calls a stored proc with a parameter and loops through the results I should be able to figure it out.
$F="NULL";
$G="NULL";
$H="Washington";
$statement = $mysqli->stmt_init();
$statement->prepare("CALL ODS.procODSCitySelect( ? , ? , ? );");
mysqli_stmt_bind_param($statement,"sss", $F, $G, $H);
$statement->execute();


while($row = $statement->fetch_array() )
{
echo "<h2>" . $row['CityName'] . "</h2>";
}
Post Reply