Php calls the stored procedure to return the result set, solving the cant return a result set in

Source: Internet
Author: User

I need php to call the stored procedure and return a result set. I found it very difficult. After searching for a long time, I finally found a solution on a foreign Forum. Here I will localize it.

Two key points

1) define (CLIENT_MULTI_RESULTS, 131072 );

2) $ link = mysql_connect ("127.0.0.1", "root", "", 1, CLIENT_MULTI_RESULTS) or die ("cocould not connect:". mysql_error ());


The following is an example program.

 

<? Php
Define (CLIENT_MULTI_RESULTS, 131072 );

$ Link = mysql_connect ("127.0.0.1", "root", "", 1, CLIENT_MULTI_RESULTS) or die ("cocould not connect:". mysql_error ());
Mysql_select_db ("vs") or die ("cocould not select database ");
?>

<? Php
$ Result = mysql_query ("call get_news_from_class_id (2)") or die ("Query failed:". mysql_error ());
While ($ row = mysql_fetch_array ($ result, MYSQL_ASSOC ))
{
$ Line = <tr> <td> <a target = _ blank href =. $ row ["url"].>. $ row ["title"]. (. $ row ["page_time"].). </a> </td> </t
R>;
Echo $ line;
Printf ("");

}
Mysql_free_result ($ result );
?>

 

<? Php
Mysql_close ($ link );
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.