<table id="node" border="1"> <caption>Table</caption> <tr> <td>id</td> <td>name</td> <td>url</td> <td>status</td> <td>Delete</td> <td>Edit</td> </tr> <?php foreach($url_list as $val) : ?> <tr> <td><?php echo $val->id; ?></td> <td><?php echo $val->name; ?></td> <td><?php echo $val->url; ?></td> <td><?php echo $val->status; ?></td> </tr> <?php endforeach; ?> </table> 

Here is the code

Closed due to the fact that the essence of the question is incomprehensible by the participants: Vladimir Martyanov , Alexey Shimansky , aleksandr barakin , katso , Kromster 15 Dec '16 at 15:44 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Please complete your question to make it clearer what you want. (Which column? What buttons? Etc.) - Yuri
  • I have a table in html, the last column in this table needs to be filled in with the buttons - Shufler3
  • Change the question by adding the table code to it and clarify your question - Yuri
  • @Yuri apparently code here: ru.stackoverflow.com/questions/603328 - Alexey Shimansky
  • <table id = "node" border = "1"> <caption> Table </ caption> <tr> <td> id </ td> <td> name </ td> <td> url </ td> <td > status </ td> <td> Delete </ td> <td> Edit </ td> </ tr> <? php foreach ($ url_list as $ val):?> <tr> <td> <? php echo $ val-> id; ?> </ td> <td> <? php echo $ val-> name; ?> </ td> <td> <? php echo $ val-> url; ?> </ td> <td> <? php echo $ val-> status; ?> </ td> </ tr> <? php endforeach; ?> </ table> - Shufler3

1 answer 1

This is how it is. But you can fill it with buttons in php code as well.

 $(function() { for(var i = 1;i < $('#node tr').length;i++){ $('#node tr').eq(i).append('<td><button data-id="delete-'+i+'">Delete</button></td><td><button data-id="edit-'+i+'">Edit</button></td>') }; }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table id="node" border="1"> <caption>Table</caption> <tr> <td>id</td> <td>name</td> <td>url</td> <td>status</td> <td>Delete</td> <td>Edit</td> </tr> <tr><td>1</td> <td>name1</td> <td>http://ru.stackoverflow.com/</td> <td>1</td></tr> <tr><td>2</td> <td>name2</td> <td>http://ru.stackoverflow.com/</td> <td>1</td></tr> <tr><td>3</td> <td>name3</td> <td>http://ru.stackoverflow.com/</td> <td>0</td></tr> </table>