Php Passing Variable Id Through Href

PHP passing variable id through href

You still need to echo it out.

<?php foreach($subjects as $sub): ?>
<tr>
<td><?php echo $sub->subject ?></td>
<td><a href="approve.php?id=<?php echo $sub->id ?>" role="button" class="btn">Add Topic</a></td>
</tr>
<?php endforeach; ?>

How to insert variable in PHP Passing ID in href

maybe you can try this :

<a href="<?php echo base_url('app_summary/hoplist/'.$row['id'].'/'.$first.'/'.$end);?>" class="large-box">

then in your controller (to show detail) you can separate $first and $end with $this->uri->segment() like this :

  $id = $this->uri->segment(3);
$frsdate = $this->uri->segment(4);
$enddate = $this->uri->segment(5);

Passing variable to another php via a href

You would use php's $GET to pass variables in the url.

<a href="Ahorro/ahorro.php/?clave=<?php echo $clave; ?>">

Would develop a url that looks like "Ahorro/ahorro.php/?clave=hello world"
And in the other file you can access that variable like this:

echo $_GET["clave"];

Would echo out:

"Hello world"

Here is a link for more information:

http://php.net/manual/en/reserved.variables.get.php

How to put a link passing variable inside php echo

Simply, put your anchor link in if condition:

<?php
if (YOUR_CONDITION_HERE) {
echo '<a href="page2.php?Id='.$Id.'">Product</a>';
}
?>

OR

<?php
if (YOUR_CONDITION_HERE) {
?>
<a href="page2.php?Id=<?php echo $Id;?>">Product</a>
<?php
}
?>

Above condition will display your link only when your condition is TRUE.

Otherwise, it will hide.

Passing id through an link href in Laravel

You need to change your route to:

Route::get('/projects/display/{id}', 'ProjectsController@getDisplay');

And then generate URL with:

{{ url('projects/display/'.$projects->id) }}


Related Topics



Leave a reply



Submit