Noob needs help!

Discussion in 'PHP' started by bbooker01, Jul 12, 2009.

  1. #1
    Hey their is a script I need to be made but I don't know where to start. Now I have come to realize that PHP is probably the best way to go when making this. I have a container and in it I want to place a random image, inside a div tag. With two other div tags so I can add content. Long story short I want it to be like the random game script on armorgames dot com. So that I will have the image, with the link, with text and a place to put in the future views and likes/the rating.
    Thanks in advanced.
     
    bbooker01, Jul 12, 2009 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well you need to store all your information in a database, and then retrieve 2 random records. Most people use MySQL as their database storage, and PHP as the scripting language which can easily communicate with this database.

    So if i've understood you correctly, you'd have a table setup in your databse (lets say its called games) with columns: game_id, image, content, link, views, rating

    Then you'd store all your games in this table, and then you can run a query to retrieve 2 random records for example:

    
    //Write out query in a variable, note the syntax, we add RAND() to return random rows, and limit the result to 2 rows
    $query = "SELECT * FROM games ORDER BY RAND() LIMIT 2";
    //Run query using mysql_query() function and store it's result (a resource) in a variable
    $result = mysql_query($query) or die(mysql_error());
    //Now 2 random rows have been retrieved from our database and stored in the $result variable, now we can display it's information how we want in our divs, by echoing them out.
    
    PHP:
    This is only a basic example and does not go on to echoing the data out, but i'm sure you get the idea. I'm not sure of your experience but learn PHP and PHP/MYSQL integration and it's easy. Here's a good link to take you step by step:
    http://www.tizag.com/phpT/
    it starts off with php but then goes into php/mysql also.
     
    wd_2k6, Jul 12, 2009 IP
  3. bbooker01

    bbooker01 Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks you so much I am going to look into this! This gives me the boost I need! Oh and do you recommend any books?
     
    bbooker01, Jul 12, 2009 IP