Reputation: 327
so I am new to codeigniter and PHP and I have a problem. I can't get the proper syntax to execute an echo within an echo. In my code, the else won't work since I'm using another php code to get the site_url() in codeigniter. Here's the code.
<td><?php if($row->homeowner_feedback == 0) {echo "Finished"; } else { echo '<button type="button" class="btn btn-custom-3" data-href="<?php echo site_url() . "user_tracking/set_finished_recent/" . $row->ticketid; ?>" data-toggle="modal" data-target="#delete-modal">Set as Finished</button>'?></td>
Upvotes: 0
Views: 281
Reputation: 5507
Just for fun, when you have an if/else that is performing the same function, in this case echo'ing something, you could use this ternary operation instead (Tested).
<td>
<?= ($row->homeowner_feedback == 0)
? 'Finished'
: '<button type="button" class="btn btn-custom-3" data-href="' . base_url() . '/user_tracking/set_finished_recent/' . $row->ticketid . ' data-toggle="modal" data-target="#delete-modal">Set as Finished</button>';
?>
</td>
Upvotes: 1
Reputation: 6994
Try like this.load url
helper first using $this->load->helper('url');
in controller.use dot(.)
for concatenation rateher than nested echo
.
<td><?php if($row->homeowner_feedback == 0)
{
echo "Finished";
} else {
echo "<button type='button' class='btn btn-custom-3' data-href='".base_url()."'/user_tracking/set_finished_recent/".$row->ticketid."' data-toggle='modal' data-target='#delete-modal'>Set as Finished</button>";
} ?></td>
Upvotes: 1