how to use multiple different a href link
on each different images? and images are getting from the `folder or directory?
Php Code
<?php
$directory = "data/uploads/bottomslider/";
if (glob($directory . "*") != false)
{
$filecount = count(glob($directory . "*"));
}
$files_index = glob("data/uploads/"."bottom"."slider/*.*");
for ($i=0; $i<$filecount; $i++)
{
$num2 = $files_index[$i];
?>
<li class="jcarousel-item"><a href=""><img src="<?php echo $num2;?>"
style="height: 119px!important; width:132px !important;"/></a></li>
<? }?>
For Example
i want like this?
<a href="google.com">Image1</a>
<a href="facebook.com">Image2</a>
<a href="yahoo.com">Image2</a>
I did not test the code. But this should work. Assuming that the folder "data" is in the root of your webpage.
$directory = "data/uploads/bottomslider/";
if(file_exists($directory)) {
$files = scandir($directory);
$output = "";
foreach($files as $key => $value) {
if($value != '.' && $value != '..' && $value != '.quarantine' && $value != '.tmb') {
$output .= '<li class="jcarousel-item"><a href="/'.$directory.$value.'"><img src="/'.$directory.$value.'"
style="height: 119px!important; width:132px !important;"/></a></li>';
}
}
//$output contains all the images.
echo $output;
}
<?php
$directory = "data/uploads/bottomslider/";
$link = "";
if (glob($directory . "*") != false)
{
$filecount = count(glob($directory . "*"));
}
$files_index = glob("data/uploads/"."bottom"."slider/*.*");
//this array must be same size like number of images
$array1 = array('www.yahoo.com', 'www.google.com', 'www.facebook.com', 'www.stackovrflow.com', 'www.blahblah.com');
for ($i=0; $i<$filecount; $i++)
{
$num2 = $files_index[$i];
$link = $array1[$i];
?>
<li class="jcarousel-item"><a href="<?php echo $link?>"><img src="<?php echo $num2;?>"
style="height: 119px!important; width:132px !important;"/></a></li>
<?php
}
?>
Give full path of link like "https://www.facebook.com/"