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
How to Convert Text to Svg Paths
How to Throw an Error Message If Username Is Already Registered
How to Store Values from Foreach Loop into an Array
Running a Python Script from PHP
Getting Check Box Values as Checked from Database Codeigniter
How to Get Filename from a Variable (Url) in PHP
Codeigniter - Call to a Member Function Result() on Boolean In
PHP Mail Function Doesn't Complete Sending of E-Mail
Showing All Errors and Warnings
How to Center the Text in Phpexcel Merged Cell
Get Selected Option in PHP Without Pressing Submit
How to Pass an Array Within a Query String
Convert Doc/Docx Files to Pdf Using PHP
Block Direct Access to a File Over Http But Allow PHP Script Access
How to Stop My PHP Form Resubmitting Input After Page Refresh