data is not passing through url

2019-08-30 16:28发布

i am trying to pass an id to a controller through url but the problem is it gives me the id field null result of the edit link is like "localhost/home71/project_management/index.php/boq_account/edit?id="

$url=base_url();
echo "<td id='edit'><a href='$url project_management/index.php/boq_account/edit?id='$n->id''>Edit</a></td>";

i have tried so many ways but not getting any result.one thing to mention that my $n->id is not null it has values but its not showing on the passing id parameter.

5条回答
不美不萌又怎样
2楼-- · 2019-08-30 17:04

You have too many single quotes near $n->id. Try something like this:

echo "<td id='edit'><a href='$url project_management/index.php/boq_account/edit?id=$n->id'>Edit</a></td>";
查看更多
放我归山
3楼-- · 2019-08-30 17:04

If you're sure you have data in $n->id, use PHP's urlencode() as you're passing it to <a>. Here's how:

echo "<td id='edit'><a href='$url project_management/index.php/boq_account/edit?id=".urlencode($n->id)."'>Edit</a></td>";
查看更多
我只想做你的唯一
4楼-- · 2019-08-30 17:13

Try like this-

echo "<td id='edit'><a href='$url project_management/index.php/boq_account/edit?id=".$n->id."'>Edit</a></td>";
查看更多
冷血范
5楼-- · 2019-08-30 17:16

Try something as below:

echo '<td id="edit"><a href="'.$url.'project_management/index.php/boq_account/edit?id='.$n.'">Edit</a></td>';
查看更多
可以哭但决不认输i
6楼-- · 2019-08-30 17:21

Try with this,

echo "<td id='edit'><a href='$url project_management/index.php/boq_account/edit?id='".$n->id."'>Edit</a></td>";
查看更多
登录 后发表回答