Rahat Islam Khan
Rahat Islam Khan

Reputation: 135

data is not passing through url

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.

Upvotes: 0

Views: 731

Answers (5)

Basit
Basit

Reputation: 1840

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

Upvotes: 0

Tomasz Madeyski
Tomasz Madeyski

Reputation: 10890

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

Upvotes: 0

Nitish
Nitish

Reputation: 2763

Try something as below:

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

Upvotes: 0

Jenz
Jenz

Reputation: 8369

Try with this,

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

Upvotes: 0

Suresh Kamrushi
Suresh Kamrushi

Reputation: 16086

Try like this-

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

Upvotes: 1

Related Questions