Retrieving mySQL data with PHP, Multiple pages with one page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

Retrieving mySQL data with PHP, Multiple pages with one page

Post by tomsace »

Hi,

Its hard to explain, but...
I have started my own online games website. I wish to load hundreds of different games but all powered from just one php file. I started the same online games website last year without mysql and I ended up with hundreds of php files each for a different game. Now I want to load it from just one.

I understand that I can load data from the mySQL database with a code along the lines of:

Code: Select all

<?php
include 'config.php';
include 'opendb.php';
 
$query  = "SELECT name, subject, message FROM contact";
$result = mysql_query($query);
 
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo "Name :{$row['name']} <br>" .
         "Subject : {$row['subject']} <br>" .
         "Message : {$row['message']} <br><br>";
}
 
include 'closedb.php';
?>
 
But how can I load 100's of games with this script? I have setup my mySQL database to locate each game with a unique ID for each game (e.g. 1, 2, 3, 4, etc...) so I suppose that I can assign the data to be loaded by its ID.

Thanks,
Tom.
killingbegin
Forum Newbie
Posts: 20
Joined: Sun Feb 08, 2009 5:07 am

Re: Retrieving mySQL data with PHP, Multiple pages with one page

Post by killingbegin »

i think you must explain better what you want
i dont know what you mean dude
Dynex
Forum Commoner
Posts: 31
Joined: Mon Feb 09, 2009 7:24 pm

Re: Retrieving mySQL data with PHP, Multiple pages with one page

Post by Dynex »

Try:

Code: Select all

$query  = "SELECT * FROM `contact`"; 
or/and

Code: Select all

echo "Name :" . $row['name'] . " <br>" .
echo "Subject : " . $row['subject'] . " <br>" .
echo "Message : " . $row['message'] . " <br>
<br>";
assuming your table is `contact`
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

Re: Retrieving mySQL data with PHP, Multiple pages with one page

Post by tomsace »

Hi,

Ok what I want to do is run multiple pages from one php file, but not including other pages but incluiding mysql data...
Post Reply