I am creating a list of products for a client. I want php to populate the name field based off the name of the folder. Then the contents of the folder I want to populate a particular place in the same row cause it all goes with that product. I have it pulling in content. But not the way that I want it to. It reads a folder but doesnt see any of its content and tries to treat the folder like a product. I have thumb nails coming in that seems to be working fine. I have a link underneath the thumbnail that I want to link to a full size image in a shadow box. I cant get that to work. On the right I have several checkboxes. I would like to be able to highlight those if there is content that would fall into them. I also need to figure out how to assign content to them(and then download them).
My Questions:
1. How to get PHP to read folder names and print them as Name of product?
2. Then get into folder and place appropriate content in the right place(or assign to
checkbox?
3. PHP to enable and disable checkboxes based off of content in folder?
4. Thumbnail to link to a full size photo in shadowbox?
5. Download select items, and/or Download All Photos?
Below is my current code and I will attach screenshots that show what I am trying to achieve and where I am at now.
<?PHP
function getNames($dir)
{
if (false === ($d = dir($dir)))
{
return false;
}
$names = array();
while (false !== ($f = $d->read()))
{
if ($f[0] != '.')
{
$names[] = substr($f, 0, -4);
}
}
return $names;
}
$baseDir = 'play/';
$descDir = $base.'play/';
$fullDir = $base.'';
$thumbDir = $base.'play/';
$products = getNames('play/');
if ($products === false)
{
echo 'Error retrieving product data';
exit;
}
foreach ($products as $p)
{
printf('<h2>%s</h2><div id="thumb"><img align="left" src="%s%s" width="100px" max-height="100px" alt="" >
<a href=\"{$p}\">Enlarge</a></div><div id="productdescription">%s</div><div id="downloadcontent">
<table width="350" border="1">
<tr>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Hi Res Photo 1</td>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Lo Res Photo 1</td>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Product Instructions</td>
</tr>
<tr>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Hi Res Photo 2</td>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Lo Res Photo 2</td>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Video</td>
</tr>
<tr>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Misc</td>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Misc</td>
<td><input name="Hi Res Photo" type="checkbox" value="hires"> Misc</td>
</tr>
</table></div>',
$p, /* product name */
$thumbDir. 'thumb', /* thumbnail directory */
$p.'.jpg', /* image thumbnail */
file_get_contents($descDir.$p.'.txt') /* product description */
);
}
?>
The first photo shows what I get when I use this code on a directory.
The second photo shows what I get when I use this code on a specific product directory.
The third photo is what I am trying to achieve.
Please Help.
Matt