Calling a MySQL Stored Procedure

Hi guys,

What's the syntax for calling a MySQL Stored Procedure, and looping through the results? (It's a bunch of queries and gives out results)

Cheers!
LVL 4
Cyber-DrugsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Raynard7Connect With a Mentor Commented:
Hi,

You should be able to treat the output as a normal query - noting that you have to use mysqli

$query = "Call dbName.StoredProc($param1, $param2)";

if ($result = mysqli_query($link, $query)) {

   /* fetch associative array */
   while ($row = mysqli_fetch_assoc($result)) {
       printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]);
   }

   /* free result set */
   mysqli_free_result($result);
}


(above is manipulation of example from http://uk2.php.net/manual/en/function.mysqli-fetch-assoc.php)
0
 
Cyber-DrugsAuthor Commented:
Cheers Raynard7! :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.