data is not passing through url

2019-08-30 16:21发布

问题:

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.

回答1:

Try like this-

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


回答2:

Try with this,

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


回答3:

Try something as below:

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


回答4:

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>";


回答5:

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>";