How do I echo datase id in base url? CI4? |
I am trying to edit user-specific information from the database using id. I have used a hidden input field for the user id but want to assign it so the form can load each user's details.
I have assigned the value of the hidden user-id field in the controller. What will be the proper syntax to edit the id using the Edit button. The method and controller work fine but not bring out user-specific form I linked to the method. I have used [color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]<?php echo base_url('/dashboard/fetch_single_data.$member['id'])?> but did not work. Kindly assist <tbody> <?php foreach ($users as $member) { ?> <tr> <td style="text-align: center;"><?php echo $member['id']; ?></td> <td style="text-align: center;"><?php echo $member['title']; ?> <?php echo $member['surname']; ?> <?php echo $member['first_name']; ?> <?php echo $member['middle_name']; ?></td> <td style="text-align: center;"><?php echo $member['work_place']; ?></td> <td style="text-align: center;"><?php echo $member['email']; ?></td> <td style="text-align: center;"><?php echo $member['member_num']; ?></td> <td><a href="<?php echo base_url('/dashboard/fetch_single_data')?>" class = "btn btn-primary">Edit</a></td> <td><a href="<?php echo base_url('/dashboard/fetch_single_data')?>" class = "btn btn-primary">Delete</a></td> </tr> <?php } ?> </tbody>
On your edit page you will need the information of that specific user. User id, or using ids will always be the best option for you.
PHP Code: <td><a href="<?php echo base_url('/dashboard/fetch_single_data').'/'.$member['id'];?>" class = "btn btn-primary">Edit</a></td> Now on your url for the edit page you will have the user id in one of the url segments. In your controller: PHP Code: $user_id = $this->request->uri->getSegment(2); // or 3 or 4 on which uri segment your id is then find the user details according to this id, and send them to the edit_user page as usual. |
Welcome Guest, Not a member yet? Register Sign In |