Okay, you need a bit more learning…
So, one of the biggest things that beginners do not think about is that code has two main parts.
First, the displayed part that the user sees on the site’s page. The second is the code behind it.
Your display has a link that has been created BEHIND the scenes. It points to your .HTML file with
the game’s name on it. So, the user does not see that part. It is viewable if they VIEW-SOURCE of
the page, but, it is kinda hidden for the average user.
Why did I explain this? Well, you can place anything you want in that link. So, you can make it a
.PHP file if you wish. That brings us to what is inside that file. If it is just a simple display of a .SWF
file which is the game, then HTML is just fine. Flash files are not secure if they are all in one’s. I mean
if the entire game is inside a flash file, it can be copied. If the flash file has code inside it to make sure
it is running only from your server, then it is secure as it will not run off a laptop or other server. But,
that is another topic. So, your page that is loaded from this routine can be simple HTML. And, of course
you would want to add a button or link on it to allow going back to the main PHP page which reloads
the games list. (Also, with a link to pass back the current page displayed in the pagination system.)
Now, the question of naming… Since server’s allow spaces in file names, you could simply rename each
of the names to fit how you want them displayed. This is okay, but, could cause other issues later on.
Another way would be to rename them with underscores ( “_” ) for spaces. This is a common way to
handle spaces in names. If you use the underscores, it is simple to replace them for displays. It is just
one string-replace function to place spaces into the name wherever there is an underscore. Another
way would be to name your games just numbers and use an array with details inside it. This might be
a better way as if a user looks at the HTML code while playing a game, they would see something like,
“1.html” or “99.html” and that doesn’t tell me much. Looking at the code that plays the flash, they can
see the “1.swf” or “99.swf” and know that, but, they will not see the name of the game at all. This is
probably a better way to go, but, involves keeping an array list of the actual game info. Now, of course,
this will be done INSIDE your games.php file so users can not see any of it. They only see what is sent
out to the browser. You just display the thumbnails, which will be just “1.jpg”, “99.jpg”, etc. And, they
will never see “Ernie’s great shoot-em-up game” title… This does mean that you need to update your
PHP code every time you add a new game!
Another way would be to use MySQL and save everything inside a database.
Oh, and your other note. The GLOB function will load a list of any type of file extension you wish. You
just change it in there. So, any filetype can be located. You could do it on .swf or .html whatever is
needed. And, lastly, if you do use an array to save the list, you can use fancy text with colors for words
or whatever as you could customize them in the array.
Just a lot of ideas for you to look into…