Home > front end >  Why do I write the code can only verify the mysql first line, unable to iterate over?
Why do I write the code can only verify the mysql first line, unable to iterate over?

Time:09-30

For example: I have a user account in the database, 1234123, 45123, 456 (3), and my code to determine the first only, and not continue to determine, actually wrong in where?

App. Post ('/register ', function (the req, res, next) {
Var connection=mysql. The createConnection ({
Host: 'localhost',
User: 'root',
Password: "'
Port: '3306',
The database: 'test'
});

Connection. The connect ();

Var users='select * from the users';
Connection. The query (users, function (err, rows) {
If (err) throw err;
for(var i=0; i If (the req. Body. Zhanghao==rows [I] zhanghao) {
The console. The log (' registration failure);
Res. The send (404, '& lt; Script> Alert (" account has been registered "); Window. The history. The back (); & lt;/script> ');
break;
}
If (the req. Body. Nicheng==rows [I] nicheng) {
The console. The log (' registration failure);
Res. The send (404, '& lt; Script> Alert (" the nickname has already occupied "); Window. The history. The back (); & lt;/script> ');
break;
}
If (the req. Body. At terumo==rows [I] at terumo) {
The console. The log (' registration failure);
Res. The send (404, '& lt; Script> Alert (" mobile phones have been registered "); Window. The history. The back (); & lt;/script> ');
break;
}
If (the req. Body. Youxiang==rows [I] youxiang) {
The console. The log (' registration failure);
Res. The send (404, '& lt; Script> Alert (" your email has been registered "); Window. The history. The back (); & lt;/script> ');
break;
}
The else {
The console. The log (' prepare registration);
The next ();
break;
}
}
})
Connection. The end ();
})
  • Related