Please visit: php code loop

Source: Internet
Author: User
Please visit: php code loop. the previous code verifies that the mysql connection is correct. what I want to achieve here is: if activite returns more than one parameter, it performs an SQL query for each parameter and then displays each query result. However, it is an endless loop, but a parameter is returned and the result is not displayed. is that the case? & Nbsp; mysql_select_db ($ mysql_database, $ link); & nbsp; please refer to php code loop.
The previous code verifies that the mysql connection is correct.
What I want to achieve here is: if activite returns more than one parameter, it performs an SQL query for each parameter and then displays each query result. However, it is an endless loop, but a parameter is returned and the result is not displayed. is that the case?
Mysql_select_db ($ mysql_database, $ link );
If (isset ($ _ POST ["activite"]) {
For ($ I = 0; $ I <count ($ activite); $ I ++ ){
$ Strsql = "select n_naps from activage where famille = '$ activite [$ I]'";
Echo $ strsql;
$ Result = mysql_query ($ strsql );
$ Nb = mysql_num_rows ($ result );
For ($ I = 1; $ I <= $ nb; $ I ++ ){
$ Info = mysql_fetch_row ($ result );
Echo" $ Info [0]
";
}
}
}
Thank you for your advice.


------ Solution --------------------
Error!
1. for ($ I = 0; $ I <count ($ activite); $ I ++ ){
$ Activite value not displayed
2. $ strsql = "select n_naps from activage where famille = '$ activite [$ I]'"
Ying writing
$ Strsql = "select n_naps from activage where famille = '{$ activite [$ I]}'"
------ Solution --------------------
The character set is 2 bytes in the Chinese operating system, and its internal code is related to the character set used.

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.