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?
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.
Reply to discussion (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]}'"
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 f ......
Moderator, thank you for answering some of my idiotic questions every time. let me explain the question in detail:
The code in 1.php is as follows:
Activit é s gymniques
Activit é s gymniques aquatiques
Activit é s fitness/forme
Activit é s douces/bien-gatetre
2. php receives parameters in 1. php: the local code is as follows:
Verify that the connected database is correct.
$ Activite = isset ($ _ POST ["activite"])? $ _ POST ["activite"]: "";
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 );
Echo $ nb;
For ($ I = 1; $ I <= $ nb; $ I ++ ){
$ Info = mysql_fetch_row ($ result );
Echo"$ Info [0]
";
}
}
}
As mentioned by the moderator, the Activit és gymniques option is selected in 1.php. the above code output is:
Select n_naps from activage where famille = 'activit é s gymniques '0
I don't know why the query result is 0. I copied and pasted the text and put it in mysql. I found four results.
Here is 0. I don't know why...
Reply to reference xuzuning on the first floor: 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 f ......
Add to the second floor. If all the items after where are removed, all n_naps will be displayed. that is to say, where is the problem, but I can't find anything wrong .... write $ strsql = "select n_naps from activage where famille = 'activit é s gymniques 'or say it is 0 ......
The character set is 2 bytes in the Chinese operating system, and its internal code is related to the character set used.