Welcome Guest, Not a member yet? Register   Sign In
Get ID from database when a specific td is clicked
#4

(This post was last modified: 01-03-2018, 09:33 AM by Wouter60.)

Since your rows are displayed by a foreach loop, you can add the row's ID to the url right away:

PHP Code:
 echo "<td><a href='http://managementtool/index.php/Home/terugbel/" $row->id "'>" $row->terugbellen "</a></td>"

Personally, I prefer to avoid echoing out the complete html and php code, because it's difficult to read (and maintain), due to the numerous double and single quotes.
In your view, you can do this to make it more readable:

PHP Code:
<?php foreach($query->result() as $row) : ?>

<tr>
   <td><?= $row->klantnaam;?></td>
   <td><a href="http://managementtool/index.php/Home/terugbel/<?= $row->id;?>"><?= $row->terugbellen;?></a></td>
</tr>

<?php endforeach; ?>

<?= is shorthand for <?php echo
Reply


Messages In This Thread
RE: Get ID from database when a specific td is clicked - by Wouter60 - 01-03-2018, 09:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB