# Php table only being able to open 1 modal

**URL:** <https://www.phphelp.com/t/php-table-only-being-able-to-open-1-modal/32558>\
**Category:** General PHP Help\
**Created:** [September 22, 2020, 11:52pm UTC](https://www.phphelp.com/t/php-table-only-being-able-to-open-1-modal/32558 "2020-09-22T23:52:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrbell11](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/c68b51/32.png) [@mrbell11](https://www.phphelp.com/u/mrbell11)\
**Post date:** [September 22, 2020, 11:52pm UTC](https://www.phphelp.com/t/php-table-only-being-able-to-open-1-modal/32558/1 "2020-09-22T23:52:04Z")

</div>

Currently I am working on adding an edit button into my page that is hooked up to a table. When you click the edit button it is supposed to open a modal. After finishing a bunch of work and trying the same system on a different page I noticed it only works with the first row in the mysql database, the rest of the data doesn’t want to open the modal. I tried both defining the data and leaving it as row data and both are still giving the issue.

There is a bunch of lines so I’m just gonna give the important stuff unless someone needs the other information.

> $query = “SELECT \* FROM users WHERE blacklisted \< ‘1’ ORDER BY id DESC”;  
> $res = $connect-\>query($query);  
> if($res-\>num\_rows \> 0):  
> while($row = $res-\>fetch\_assoc()){  
> $userid = $row[‘id’];  
> ?\>  
> `<td> <a href="#edituser<?php echo $userid; ?>" data-toggle="modal"><button class='btn btn-primary' type='button'>Edit</button></a> </td>`

This is the main information for the modal

`<div class="modal fade" id="edituser<?php echo $userid; ?>">`

I know I kept it to the bare minimum but my code has a very large number of lines for example if statements in the modal that are unnecesary since they technically work

---

<div class="post-metadata">

**Author:** ![skawid](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@skawid](https://www.phphelp.com/u/skawid)\
**Post date:** [September 24, 2020, 3:07pm UTC](https://www.phphelp.com/t/php-table-only-being-able-to-open-1-modal/32558/2 "2020-09-24T15:07:10Z")

</div>

This looks like you’re rendering a separate modal for each user; so you have something like;

```
<td><a href="#edituser1" data-toggle="modal">...</a></td>
<td><a href="#edituser2" data-toggle="modal">...</a></td>
<td><a href="#edituser3" data-toggle="modal">...</a></td>

...

<div class="modal fade" id="edituser1">...</div>
<div class="modal fade" id="edituser2">...</div>
<div class="modal fade" id="edituser3">...</div>

```

in your rendered page. Is that right?
