Click to See Complete Forum and Search --> : Probably in over my head


mikemdperf
11-13-2008, 05:58 PM
I have very limited web design experience, but I've been given then task of creating a new website for my company. I have plenty of ideas of what I want it to look like, but I'm not sure how to implement them. I'm hoping some of you can help...btw, I'm using Dreamweaver CS4...

The problem I'm trying to tackle now is that I want to create a division on the home page that will randomly pull a few images with associated descriptions for a "Monthly Specials" display. The goal is to be able to upload a new database each month containing that month's specials, and every time someone visits the home page, they'll see different products in the "Specials" division.

My servers currently have mySQL and phpmyadmin...I'm not familiar with them, and I'm not sure if that's what I need to be able to integrate this feature into the page. Can anyone help me out? Thanks!

scragar
11-13-2008, 06:15 PM
$dir = './images';// no / at end, IMPORTANT!!
$show = 5;// show how many images.

$imgs = array();

if($dh = @opendir($dir)) {
while($tmpFile = readdir($dh)){
if(is_file($dir.'/'.$tmpFile))
$imgs[] = $dir.'/'.$tmpFile;
}
closedir($dh);

while(count($imgs) && $show){
$rand = rand(0, count($imgs)-1);
echo '<img src="'.$imgs[$rand].'">';// EDIT THIS AS YOU WANT
$show--;
$imgs[$rand] = $imgs[count($imgs)-1];
unset($imgs[count($imgs)-1]);
}
}else{
echo 'unable to open images directory for reading.';
}

EDIT: fixed a minor error(un-needed semicolon) and cleaned up a bit of the code.

EDIT 2: bit more clean up and stuff.