A piece of logic judgment cannot achieve the goal

Source: Internet
Author: User
A piece of logic judgment cannot achieve the goal. I want to use only one page for help and display three functions of the news system: & quot; index. php? News_title = xxx? News_class = xxx & quot;, to achieve the following goals: 1. when the news_title and news_class elements are empty or both have values, this page displays a list of all news titles; 2. a logical decision cannot be achieved.
I want to use only one page to display three functions of the news system: "index. php? News_title = xxx? News_class = xxx ", to achieve the following goals:

1. when the news_title and news_class elements are empty or both have values, this page displays a list of all news titles;

2. when one element contains a value and another element without a value, the page displays the element with a value.

------ Algorithm logic and code implementation:
PHP code
  // First, obtain the pass-through values of the browser: news_title and news_classif (isset ($ _ GET ['news _ class']). {$ news_class =$ _ GET ['news _ class'];} else {$ news_class = '';} if (isset ($ _ GET ['news _ title']) {$ news_title = $ _ GET ['news _ title'];} else {$ news_title = '';} // then start to judge and prepare to display the relevant content if ($ news_title ='') // when the news_title element is empty, start to judge whether the news_class element is null {if ($ news_class = '') // news_class is also empty, this page displays the news_title list of all news tables {$ SQL = "SELECT news_title, in_time FROM news"; $ resu Lt = mysql_query ($ SQL); while ($ row = mysql_fetch_assoc ($ result) {?>                  
          
                
                                 
                
                    
                                  
  Author:
  Date:
                         
                
                                 
            
                
  


The above code is displayed as a news title list, namely, the new_title list.

I am afraid to ask you about this logic. Is there a problem with writing?


------ Solution --------------------
You cannot write well.

Your request data is integrated with the logic and html code,
It is best to make logical judgments first. Request data again. The last foreach outputs html.

It seems that your code is hard to write again. ===Zzz
------ Solution --------------------
Index. php? News_title = xxx? News_class = xxx
Parameter string in, not a regular format
Is index. php normal? News_title = xxx & news_class = xxx

What you get is array ('news _ title' => 'XXX? News_class = xxx ')
Available only after processing

------ Solution --------------------
PHP code
If ($ a & $ B) {// show All} elseif ($ a) {;} elseif ($ B ){;}
------ Solution --------------------
Index. php? News_title = xxx & news_class = xxx

$ News_title = $ news_class = '';
If (isset ($ _ GET ['news _ title']) $ news_title = $ _ GET ['news _ title'];
If (isset ($ _ GET ['news _ class']) $ news_class =$ _ GET ['news _ class'];

If ($ news_title! = ''& $ News_class! = ''){
// Both have

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.