Query statement problems

Source: Internet
Author: User
The problem database of query statements is mssql. Run this statement in the query analyzer. However. I use different results on my website.

Select top 6 * from WEB_VIEW where DNBH = '$ username' order by SFMonth desc

In the mssql query analyzer, run and get 6 latest results. However, you can only get 5 records for testing on the page, but the latest one is missing.

Should I change 6 to 7?

// Connection to the database $ dbhandle = mssql_connect ($ myServer, $ myUser, $ myPass) or die ("unable to connect to database "); // select a database to work with $ selected = mssql_select_db ($ myDB, $ dbhandle) or die ("unable to connect to the specified database "); $ username = trim ($ _ POST ['username']); $ password = trim ($ _ POST ['pass']); // declare the SQL statement that will query the database $ query = "select top 6 * from WEB_VIEW where DNBH = '$ username' order by SFMonth Desc "; // execute the SQL query and return records $ result = mssql_query ($ query) or die (" Data query failed :". mysql_error (); $ numRows = mssql_num_rows ($ result); $ nRow = mssql_fetch_array ($ result); if ($ password <> substr ($ nRow [3], -4) {echo "incorrect input. enter the user name and password correctly. Thank you! ";}Else {if (empty ($ numRows) echo" no data found. please enter the user name and password correctly. Thank you! "; Else {// $ nRow = mssql_fetch_array ($ result); echo" Hello! The computer number is "; echo" $ username "; echo", "; echo" account name "; echo" $ nRow [2] "; echo"


Row 18th has $ nRow = mssql_fetch_array ($ result); read the first record
So there is one missing
The 38-48 lines of code should be changed
Do {
Echo"








I don't need to query the password twice.

I will adjust it again.

Use two SQL statements. I can't think of any good solutions.

"; While ($ row = mssql_fetch_array ($ result) {echo" "; Echo" "; Echo" "; Echo" ";}Mssql_close ($ dbhandle );}} Reply to discussion (solution) ";Echo" ";Echo" ";Echo" ";} While ($ row = mssql_fetch_array ($ result )); Do wuile loop instead of while loop
Month Total cost
"; Echo $ row [1]; echo""; Echo ($ row [10] + $ row [4]); echo"
";
Echo $ row [1];
Echo"
";
Echo ($ row [10] + $ row [4]);
Echo"

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.