Problems related to UNION and WHERE

Source: Internet
Author: User
$ Id] for UNION and WHERE; $ id & quot; whereWebMailUserN & quot; from another page hyperlink ;. $ id; -- traverses the data in all tables in the array and displays the field content $ tablearray (& quot; content_201202 & quot;, & quot; content_201203 & q about UNION and WHERE
$ Id = $ _ GET ['id']; // The value sent from another page hyperlink
$ Id = "where WebMailUserN =". $ id;
// -- Traverse all the table data in the array and display the field content
$ Table = array ("content_201202", "content_201203", "content_201204 ");
$ Select = array ();
Foreach ($ table as $ v ){
$ Select [] = "(select * from $ v $ id )";
}
Echo $ sqll = join ('join', $ select );
$ Sqll = mysql_query ($ sqll );
$ Num = mysql_num_rows ($ sqll); // The total number of records.

$ Sqln = join ('join', $ select). "limit $ page $ pagesize ";
$ Sqln = mysql_query ($ sqln );
While ($ row = mysql_fetch_array ($ sqln )){.......}

(Select * from content_201208 where WebMailUserN = $ id) UNION (select * from content_201209 where WebMailUserN = $ id) UNION (select * from content_201210 where WebMailUserN = $ id)
Warning: mysql_num_rows (): supplied argument is not a valid MySQL result resource in F: \ www_local \ G04 \ list_content.php on line 49

Warning: mysql_fetch_array (): supplied argument is not a valid MySQL result resource in F: \ www_local \ G04 \ list_content.php on line 53


The above code does not know the error and does not display data.

------ Solution --------------------
You need to upload the id to the next page in the url.

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.