Sunday 15 June 2014

php - mysql query within a mysql query -


I am trying to display information in a table in a table in my own loop, but for some information, I have referenced other tables when I try to get data from other tables, then any data will disappear. Here is the code I am using:

`

  // is the SQL query below $ listing = mysql_query (" Select from musicians "from selectors); / / This is showing the results of the SQL query while ($ row = mysql_fetch_array ($ list)) {? & Gt; html here ... ... echo ['name'];? & Gt; Repeat every [= 'Town']?? & Gt; Ke & lt;? $ Countyfront = $ line ['countyID']; $ county = mysql_query ("Select * From County where couient = ' $ County Rough ''); while ($ line = mysql_fetch_array ($ County)) {Echo $ line ['CouName'];}? & Gt; & lt ;? php echo $ row ['tool'];? & Gt; & lt ;? php echo $ row ['style']; ? & Gt; `  

My problem is, is there any other suggestion after the other that the loop is not displayed?

Thanks

You can do this with a single query:

  select *, (Select from CouName FROM County WHERE CouInt = mus.CountyId) as a country from musicians;   

You should look like the final code:

  & lt ;? Php $ listing = mysql_query ("SELECT *, (SELECT CouName from COUNTRY WHERE CouInt = mus Kondied) as the country from musicians;"); // This displays the results of SQL queries ($ row = mysql_fetch_assoc ($ listings)) {echo $ row ['name']; Echo ['Town'] per line; Echo ['country'] per line; // xD echo $ row ['instrument'] to all people; Echo ['style'] per line; }? & Gt;   

Saludo;)

No comments:

Post a Comment