Reputation: 91
row['filename']
below contains a filename fetched from database. I want to send the filename to download_file.php
when the link is clicked.
<?php
//other code
$filename=$row['filename'];
echo '<a href="download_file.php?name=$filename">' . "See file name" .'</a>';
?>
but in download_file.php
I get only the word $filename
instead of its value (the actual filename fetched from the db). How can I pass the value of $filename
to download_file.php
? Where did I go wrong in my code?
Upvotes: 1
Views: 1480
Reputation: 28763
Try like
echo '<a href="download_file.php?name="'.$filename.'>See file name</a>';
Or you can directly use "
double quotes like :
echo "<a href='download_file.php?name=$filename'>See file name</a>";
Upvotes: 4
Reputation: 887
You used apostrophes as a string mark. If you use quotation marks you can use the anchor like that.
echo "<a href='download_file.php?name=$filename'>See file name</a>";
Upvotes: 2
Reputation: 2556
In single quotes you can't get the value of variables only with double quotes.
change to:
echo "<a href='download_file.php?name=$filename'>See file name</a>";
Upvotes: 2