-1

I am trying to get values from different columns, but from the same line. For example: get username, password, email address and by only knowing the username. So for example: user logins and wants to see some data related to them that is stored in the database, so I would get all the data from the line and then only display the data that I need, like his email address.

Example:

id  | Username | Password |   Email    | 
----+----------+----------+------------+
 1  | Ane      | 1234567  |  ok@ok.com |
 2  | Angi     | 1234567  |  ok@ok.com |
 3  | Bobby    | 1234567  |  ok@ok.com |
 4  | Denis    | 1234567  |  ok@ok.com |
 5  | Jerry    | 1234567  |  ok@ok.com |
 6  | Mikha    | 1234567  |  ok@ok.com |

So I want to get for example all the values from Username Mikha, so:

ID, Username, Password, Email

6, Ane, 1234567, ok@ok.com

  • 2
    There are ***100000*** of simple SQL tutorials on the web. ***Read a few*** – RiggsFolly Apr 03 '18 at 16:41
  • Have you tried anything yet? A `fetch` on a result set should work. – chris85 Apr 03 '18 at 16:41
  • @chris85 I think they are asking for the query first, the how do I make it work in PHP will probably come next – RiggsFolly Apr 03 '18 at 16:42
  • A little quick search and you pretty much get the answer for something as basic as this... take a look at PHP's [mysqli prepare](http://php.net/manual/en/mysqli.prepare.php) - First example, specifically – Rushikumar Apr 03 '18 at 16:44
  • FYI: **Never store plain text passwords!** PHP provides [`password_hash()`](https://php.net/manual/en/function.password-hash.php) and [`password_verify()`](https://php.net/manual/en/function.password-verify.php) please use them. If you are using a PHP version prior to 5.5 [there is a compatibility pack available here](https://github.com/ircmaxell/password_compat). Make sure you [**don't escape passwords**](https://stackoverflow.com/q/36628418/5914775) or use any other cleansing mechanism on them before hashing. Doing so changes the password and causes unnecessary additional coding. – Tom Udding Apr 03 '18 at 17:01

1 Answers1

1

simply type:

select (id,Username,Password,Email) from theTable where username = "Mikha";

This will printout all the value from row where username = "Mikha" exist.

Ninja
  • 175
  • 12