How to print the results of listing multiple select statements in loop append?

Source: Internet
Author: User
How to repeatedly append and print the results of listing multiple select statements first: $ names = array ("Keyword 1", "keyword 2", "keyword 3 ");


Then select the keywords and print them out. The following program can only print the result of the last keyword 3. Please help solve the problem. O (∩) O thank you

For ($ I = 0; $ I $ Query = "SELECT * from te where title like \" $ names [$ I] \ "";
$ Result = @ mysql_query ($ query) or die ('query statement error: '. mysql_error ());

While (!! $ Row = mysql_fetch_array ($ result )){
Echo $ row ['id']. '----'. $ row ['title']. '----'. $ row ['URL'];
Echo'
';
}}


Reply to discussion (solution)

Are there no search results for the first two?

So what? Only keyword 3 has results.

Like has no wildcard, which is equal to the = sign. The data in your table does not contain title = keyword 1 or title = keyword 2 d.

Are there no search results for the first two? Yes. Only the matching results of search keyword 3 are printed. What if I want the results of all three keywords to be displayed? I suspect it is a while problem.

Like has no wildcard, which is equal to the = sign. The data in your table does not contain title = keyword 1 or title = keyword 2 d. Yes. Even if I customize three data arrays, only the matching results of the third data can be displayed. I want to list all three keywords.

So what? However, it is only the result of keyword 3. the moderator, I want to list all the results of the three keywords. Not just the matching results of 3rd keywords

I don't quite believe it. you can paste your table data and page output results into a graph.

First, let's clarify the difference between "include" and "equal ".

Use title like "% {$ names [$ I]} %"
Or INSTR (title, "{$ names [$ I]}")

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.