Search code examples
phpmysqlloopsfacebook-loginlogin-control

Can we run a loop in a column of mysql table?


Through php, I have to take input of user name and then search for the same in column named as useername of mysql table.

If username matches, it looks for matching the password of the same row, so is it possible to run a loop that tries to match the data?

If yes what should it be like? If not please tell me some alternative.


Solution

  • You need to learn about SQL queries, I really can't answer any better than that. SQL is used to select data from database, you could use a command like:

    Select employeeID from table where username = 'user' and password = 'password'
    

    If you get a record return there has been a match. Essentially, if you do a query like "give me data that matches this query" the database server does loop over all the dta and tries to find any row the matches. To it already loops over all the data, there is no need to do it by hand.

    Again: Please learn something about SQL. By the question you are asking it's obvious you are missing a very basic understanding. This will kill your time (trying useless things) and possibly harm others (if you ever let you code run in the public).