Let's take a step back here! It's nice you're learning this versatile language but to maximize your ability, start off with the very basics, clean code, and up to date code. For example using shorthand php tags (<?) is unwise, if you were to import that on a server which didn't allow shorthand tags, imagine, a large website having to find all of the shorthand tags and replace them with the standard <?php ?>.
Second, I just think it's better practice to choose are you going to use double or single quotes, double quotes don't need concatenation for variables, in other words:
echo "Hello $sUsername";
Works just the same as
echo 'Hello ' . $sUsername;
So to concatenate double quotes is extraneous.
One of your problems in the code right from the get-go is you're trying to echo an array, which isn't really possible you want the keys/values from the array not the array itself! so,
won't work, because it's simply an array. You also don't need to use the
$key => $value
structure in the foreach array,
$imagedata as $image
is just fine. I've altered your index.php as per these recommendations and it works fine for me.
<?php include('data.php'); ?>
foreach ($imagedata as $image)
echo '<a href="detail.php?f=' . $image['filename'] . '">';
echo '<img src="thumbs/' . $image['filename'] . '" alt="A kitten" /></a>';
echo '<p>' . $image["title"] . '</p>';
Viola, nice running clean code. However although this works
, it does not meet the requirements of your homework, as the criteria for the url argument was not the file name although it works but rather the id, which would be like 0,1,2,3 - as per it's position in the array.
The solution is easy, and will require you to use
$key => $value
in the foreach like you had before
Then echoing the $id value in the <a> tags.
Then there will be a little modifying to do on the display page; nothing you can't figure out, try it out.