A
A
arab_fox2015-12-06 13:06:26
Database
arab_fox, 2015-12-06 13:06:26

How to make a selection from the database id = name?

There is a database, it has an id column, and a name next to it.
It is necessary that for each user who is assigned an id, a name is displayed.
I don’t know how to implement it, I’m racking my brains for the second day :(
UPD. Displays only the 1st value from the table.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dauren Bablan, 2015-12-06
@dauren88

1. When a user logs into his account, save his "id" to the session ($_SESSION['id']) = $id;
2. Then SELECT name FROM table WHERE id = $_SESSION['id'];
If I understand correctly then

D
Dmitry, 2015-12-06
@mytmid

SELECT name FROM table WHERE id = 1
Or I didn’t understand something ... o_O

S
Stanislav, 2015-12-06
@mzcoding

set the id field to the AUTO_INCREMENT attribute so that each user has a unique id. And then, as they wrote above, remember the id at the entrance and choose a name using this id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question