I would set your database up like so.
tablecompany
id company otherstuff
tableusernamepass
compid username password
Make the ID in the tablecompany auto_increment then test the
tableusernamepass compid
against it when the user properly logs in. Exampe of the entries in the
database:
tablecompany
1 Company 1 All the other stuff
2 Company 2 A Different company
tableusernamepass
1 Username Password
2 Username Password // A user for company 2
2 AnotherUser Password // A user for company 2
2 AnotherUser Password // A user for company 2
That should give you an idea.
Hope this helps.
Regards,
Ray