Why can't data be found for such nested queries?

Source: Internet
Author: User
Why can't we find the structure and data of the data table "Product" in this nested query: PHPcodeinclude_once ('Conn. php '); $ result = mysql_query (& quot; SELECTp_classFROMProductgroupbyp _: why can't data be found?
Structure and data of the data table "Product:



PHP code
  Include_once ('Conn. php '); $ result = mysql_query ("SELECT p_class FROM Product group by p_class limit 40"); // For the first query, the data mysql_data_seek ($ result, 0) is successfully obtained ); while ($ row = mysql_fetch_row ($ result) {for ($ I = 0; $ I
  


The code above indicates that the number of loops is correct. the first query is correct, that is, the second query has no data.

------ Solution --------------------
You $ row = in while and then $ row = .... change the 2nd $ row to $ row2 = to be consistent with the subsequent values. let's change it first. I haven't checked your code carefully.
------ Solution --------------------
This is the same as your problem.
Mysql_fetch_row
Change to mysql_fetch_assoc ()

Generally, we return the associated array.
------ Solution --------------------
You are using
Join array
Echo $ row ['Pic ']; // no data found here
Echo $ row ['p _ class']; // same as above
Echo $ row ['p _ name']; // same as above

So you have to return the joined array to match the number... If you do not understand it, you can check the structure of the returned result print_r.

Generally, the returned results are associated arrays, which makes it easier to write code. this is not to say that it is only recommended. it depends on the actual situation. In most cases, we need to use more correlated arrays. of course, you can also use mysql_fetch_array to return two formats ....

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.