Reputation: 45
This one is my code to display at email , my folder got 5 item , but it only display one link only , by right it should display 5 link
$files = glob("../booking/file/".$id."/*.*");
for ($i=0; $i<count($files); $i++)
{
$image = $files[$i];
$supported_file = array('gif','jpg','jpeg','png', 'pdf');
$d = $i + 1;
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
$attch = '<a href="localhost/linxtravel/travelnew/travelnew/'.$image.'" target="_blank">('.$d.') Click here to download.</a><br/>';
$checkattch = 1;
} else {
continue;
}
}
Upvotes: 1
Views: 70
Reputation: 19780
You have to concatenate the string using .=
:
$attch .= '<a href="localhost/linxtravel/travelnew/travelnew/'.$image.'" target="_blank">('.$d.') Click here to download.</a><br/>';
Without, you overrides the variable $attch
and you gets only the last link.
Upvotes: 1
Reputation: 1391
In this place you always rewrite variable $attch
each loop:
$attch = '<a href="localhost/linxtravel/travelnew/travelnew/'.$image.'" target="_blank">('.$d.') Click here to download.</a><br/>';
You need to append like this:
$attch. = '<a href="localhost/linxtravel/travelnew/travelnew/'.$image.'" target="_blank">('.$d.') Click here to download.</a><br/>';
And declarate variable before loop for
:
$attch = '';
Upvotes: 1