+ 1

How can I give different for ids for a <button> in a while loop?

I have written a while loop in php to echo data from a database. I used an onclick javascript code for the button in the loop to hide photos unless the button is clicked. Now the problem is, since i used an id for the button in the hide function, no matter how much data that is printed, clicking the button only shows one photo(always the first div printed) and the rest don't show anything although when i use the browsers inspect elements, i see the photos in the source code. Thanks very much for ur answers.

4th Apr 2018, 11:01 AM
Ondape Valery
Ondape Valery - avatar
4 Réponses
+ 1
Ondape Valery please can you attach your code here,
4th Apr 2018, 11:07 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
https://code.sololearn.com/WYLRNpFN4KFI/?ref=app That's the code Shudarshan Rai the id is hideplay. The javascript is included. I didnt include the database queries
4th Apr 2018, 1:27 PM
Ondape Valery
Ondape Valery - avatar
0
If I understood correctly, maybe use classes instead of ids?
4th Apr 2018, 11:11 AM
Bebida Roja
Bebida Roja - avatar
0
Bebida Roja let me try using a class.
4th Apr 2018, 1:17 PM
Ondape Valery
Ondape Valery - avatar