So I started learning this PHP when I realized that a site without a backend is no site at all. My first 'script' manages a collection of Flash browser games and has, a whopping two files currently.
MySQL:
Two tables, Stress Relievers and Action, both containing four text fields, Code, Author, Desc, GameName
The two files, one that just lists the tables, and the other that lists the games. Just two functions and 40 lines.. big whoop.
The first file, that displays the "Categories" aka Table names goes like this:
(Ignore the "Name," "Position" titles.. they were in the tutorial I was reading and my lazy ass didnt change it..)
<?php
$db = mysql_connect("99.999.99.99", "Games", "Boo");
mysql_select_db("Games",$db);
$tablename = mysql_list_tables("Games");
for ($i = 0; $i < mysql_num_rows($tablename); $i++)
printf ("<b>Table:</b> %s\n", mysql_tablename($tablename, $i));
?>
The second file that displays all the games goes like this:
<?php
$db = mysql_connect("99.999.99.99", "Games", "Boo");
mysql_select_db("Games",$db);
$result = mysql_query("SELECT * FROM Action",$db);
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Position</td><td>Job</td><td>Rank</td></tr>\n";
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$myrow[0], $myrow[1], $myrow['2'], $myrow[3]);
}
echo "</table>\n";
$gamecount=mysql_numrows($result);
echo "There are currently $gamecount games in this category!<br>";
?>
As you can see, in the second file, which displays the game, this line donates what Category's games will be displayed:
$result = mysql_query("SELECT * FROM Action",$db);
This line opens the Action table and lists all the crap in it. What I need to do, is that when the person clicks on a "Category" in the first file, the varibale Action, which really isnt a variable but will need to be, changes to the Category clicked.
Im just trying to learn PHP, so if you alter my script (ehehehe, it shoudlnt even be called that..) include lots of comments so I dont have to read through the PHP Manual on PHP.net again.. I swear that thing is giving me nightmares... :mad: