Jump to content

Recommended Posts

i am having trouble writing this code:

 

<a href='downloadFile.php?file=<?php echo $_FILES[file][name]?>'>

 

i always get confused when it comes to echoing/printing php code.  i tried closing with '" . php code...here . "', but it didn't seem to work.  the link goes to (when clicked on), ?file=<?php echo [name]?>

Link to comment
https://forums.phpfreaks.com/topic/242337-printing-php-code/
Share on other sites

print("</td>");
		print ("<td align='center'><input name='file[]' type='checkbox' value='$file' /></td>");
		print ("<td>" . date ('F d Y H:i:s.', filemtime($file)) . "</td>");
		print ("<td><a href='downloadFile.php?file=<?php echo $_FILES[file][name]?>'><img src='http://www.mysite.com/Images/icn_file_download.png' width='50' height='50' title='Download this file!' /></a></td>");
        }
}

Link to comment
https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244632
Share on other sites

Thanks:

 

print "<td><a href='downloadFile.php?file=". $_FILES['file']['name'] . "'><img src='http://www.mysite.com/Images/icn_file_download.png' width='50' height='50' title='Download this file!' /></a></td>";

 

Is what you should be using. When you are echoing a variable inside of PHP code, you need to concatenate variables onto it (like I just showed you). If you are working out side of PHP, then you would use the echo like you had:

 

?>
<some html here>
<td><?php echo $var; ?></td>
<?php
// more php code
?>

 

Hopefully that makes sense to you.

Link to comment
https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244633
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.