Codeigniter variable for url

I have a list of posts and a link editfor each. When clicked, editit goes to a page where I can edit the specific entry that I clicked on. To do this, I will have to extract the message identifier from db.

Would this be the right way?

<a href="<?php echo site_url("post/edit/$row->id"); ?>">Edit</a>

post- my controller, edit- is my function, but $row->idshould output a message identifier.

+3
source share
4 answers

Yes, it seems right to do

<a href="<?php echo site_url("post/edit/".$row->id); ?>">Edit</a> 

Just make sure your action method (editing in this case) accepts an argument with the message id you need to extract.

+7
source

, , SO... ,

+2

PHP $row- > id . , EG: site_url("post/edit/".$row->id)

+2
source

This is correct ... Your code will cause an error

<a href="<?php echo site_url("post/edit/{$row-> id} ");?>"> Edit </a>
+2
source

Source: https://habr.com/ru/post/1784410/


All Articles