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.
| Month |
Total cost |
"; While ($ row = mssql_fetch_array ($ result) {echo"
"; Echo"
| "; Echo $ row [1]; echo" | "; Echo"
"; Echo ($ row [10] + $ row [4]); echo" | "; Echo"
";}Mssql_close ($ dbhandle );}} Reply to discussion (solution)
";Echo"
"; Echo $ row [1]; Echo" | ";Echo"
"; Echo ($ row [10] + $ row [4]); Echo" | ";Echo"
";} While ($ row = mssql_fetch_array ($ result )); Do wuile loop instead of while loop