转自:http://www.robert-gonzalez.com/2007/06/01/mysql-multiple-result-procs-in-php/

 

<html>
<head><title>Stored Procedure Tester - MySQL</title></head>
 
<body>
< ?php
$sql = '';
$show_results = false;
 
if (isset($_POST['form_submitted']))
{
    
// The form was submitted
    $sql = $_POST['query'];
 
    
echo '<p>The query you entered entered was <strong>' . $sql . '</strong>.';
 
    
// Change the params to you own here...
    $mysql = new mysqli('localhost', 'USER', 'PASSWORD', 'DATABASENAME');
 
    
if (mysqli_connect_errno())
    {
        
die(printf('MySQL Server connection failed: %s', mysqli_connect_error()));
    }
 
    
// Check our query results
    if ($mysql->multi_query($sql))
    {
        
$show_results = true;
        
$rs = array();
 
        
do {
            
// Lets work with the first result set
            if ($result = $mysql->use_result())
            {
                
// Loop the first result set, reading it into an array
                while ($row = $result->fetch_array(MYSQLI_ASSOC))
                {
                    
$rs[] = $row;
                }
 
                
// Close the result set
                $result->close();
            }
        } 
while ($mysql->next_result());
    }
    
else
    {
        
echo '<p>There were problems with your query [' . $sql . ']:<br /><strong>Error Code ' . $mysql->errno . ' :: Error Message ' . $mysql->error . '</strong></p>';
    }
 
    
$mysql->close();
}
 
echo '<form >?>

相关文章:

  • 2021-07-19
  • 2022-03-02
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-16
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2022-02-26
  • 2021-06-22
  • 2022-12-23
相关资源
相似解决方案