Old problems related to changing the color of the line

Source: Internet
Author: User
What is the old problem of changing colors in different lines? To enable the function of changing the color of the line on the webpage, I used the second method below. Theoretically, it is okay. The result is all in one color. I checked it later, there is also the first method, which is quite useful. I just want to know that there is a problem in the second method, and I am very confused. I used to do this. I checked a lot of information and didn't explain it in detail. please advise me ...... PHPcode method 1 while ($ resultmysql_fetch_array is the old problem of changing colors in the line?
To enable the function of changing the color of the line on the webpage, I used the second method below. Theoretically, it is okay. The result is all in one color. I checked it later, there is also the first method, which is quite useful. I just want to know that there is a problem in the second method, and I am very confused. I used to do this. I checked a lot of information and didn't explain it in detail. please advise me ......

PHP code
  // Method 1 while ($ result = mysql_fetch_array ($ query) {$ bgcolor = ($ bgcolor = "blue ")? "White": "blue"; echo""; Echo"{$ Result ['gname']}"; Echo"{$ Result ['endtime']}"; Echo"{$ Result ['current _ price']}"; Echo"{$ Result ['reply _ num']}"; Echo"";}// Method 2 $ flag = 1; while ($ result = mysql_fetch_array ($ query) {if ($ flag % 2 = 0) $ bgcolor = "yellow"; else $ bgbolor = "white"; // This method can theoretically be echo""; Echo"{$ Result ['gname']}"; Echo"{$ Result ['endtime']}"; Echo"{$ Result ['current _ price']}"; Echo"{$ Result ['reply _ num']}"; Echo""; $ Flag ++ ;}


------ Solution --------------------
Why don't jquery do it on the front end ?? Code remainder efficiency is a problem
------ Solution --------------------
If ($ flag % 2 = 0) $ bgcolor = "yellow"; else $ bgbolor = "white ";

$ Bgcolor !!!

I wrote something wrong. who is the blame?
------ Solution --------------------
Output $ flag % 2 first
Echo $ flag % 2; echo'
';
Check whether the x0x0x0x0x0 format is correct. If yes. Check whether it is a css style problem.
Style = "background: Color"
------ Solution --------------------
Discussion
If ($ flag % 2 = 0) $ bgcolor = "yellow"; else $ bgbolor = "white ";

$ Bgcolor !!!

I wrote something wrong. who is the blame?

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.