Hey all, As of now i'm using a image rotation script on a main page. It pulls images from my folder and then displays them (nothing fancy) Anyway, i'm kinda stuck when it comes to adding a link on it. the script: <? $imglist=''; $img_folder = "thumbs/"; mt_srand((double)microtime()*1000); $imgs = dir($img_folder); while ($file = $imgs->read()) { if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file)) $imglist .= "$file "; } closedir($imgs->handle); $imglist = explode(" ", $imglist); $no = sizeof($imglist)-2; $random = mt_rand(0, $no); $image = $imglist[$random]; echo '<img src="'.$img_folder.$image.'" border=0>'; ?> Code (markup): I tried adding the link around it, but then it will just give a link to the main page of the site as php won't read the $image in that part (or so i think) Any ideas?
echo "<img src=".$img_folder.$image." border=0>"; // if folder variable have / at the end echo "<img src=".$img_folder."/".$image." border=0>"; // if folder variable don't have / at the end PHP:
I see what i had wrong now And so i changed it to: echo "<a href='myurl'><img src=$img_folder/$image border=0></a>"; Code (markup): Thanks a lot, qualityhostings. Rep added.