PDA

View Full Version : [How to?] Create a page w/Games



AnyWay
04-14-2010, 11:00 AM
Hello,
Can somebody tell me how to write a new page with a selection of games (random, by cat...)?

Thanks.

GoalieGuy6
04-14-2010, 11:57 AM
Someone may be able to help you once you verify your license ;)

Bad Wolf
04-14-2010, 12:03 PM
yea get verified and we can help you out. What you want is quite simple actually.

AnyWay
04-14-2010, 12:18 PM
How to get verified?

Nevermind, i think i've found how to verify it.

Bad Wolf
04-14-2010, 03:32 PM
How to get verified?

Nevermind, i think i've found how to verify it.


Musta worked, your a smurf now like the rest of us LOL. I will have to give you a tut on this topic tomorrow though. Got classes till 9 tonight and I gotta leave in like 20 miniutes. Maybe Goalie will take care of you before then :D

AnyWay
04-14-2010, 03:50 PM
Eheh ok, thank you all.
Have a good day, Bad Wolf.

-M-A-R-K-
04-14-2010, 06:18 PM
You can use this query in your PHP page


SELECT * FROM ava_games WHERE category_id="[ID]" AND published=1 ORDER BY rand()

Replace ID with your category ID

AnyWay
04-14-2010, 06:28 PM
I have this query that should give me 10 random games, each time:
$sql = mysql_query("SELECT * FROM ava_games WHERE published=1 ORDER BY rand() LIMIT 10");
I have the html code to display games, also.

What i don't have/know is the code to write in the php page to let the sql query work. Should i include something? Is there any doc i can read?

Thanks for the help.

GoalieGuy6
04-14-2010, 08:38 PM
What exactly are you trying to do? Are you creating a page through your admin panel? If you want to include PHP (which it seems you do), you might want to look at the custom PHP page mod in the add-on forum.

AnyWay
04-14-2010, 09:09 PM
No, i'm making a .php file.
In this file i'd want 10 random games to appear.

GoalieGuy6
04-14-2010, 09:20 PM
Ok, have you taken a look at the custom php page mod?

Bad Wolf
04-14-2010, 09:39 PM
Darn I hate it when I can help out but cant get to my stuff. I have random games all over the place in all of my arcades. That part is super simple. But I dont recall off hand the code. I really dont like to access files on public computers. Still got 3 hours of class for the day. And a 2 hour class in the morning. But if we have'nt got you straight by then I will hook you up :)

Bad Wolf
04-15-2010, 03:44 AM
Ok for you new page go here and get this

http://forum.avscripts.net/showthread.php?t=4916

For your random games do this

In your includes folder;

create a new file called random_games.php

Paste this in it;

**NOTE - The parts in green and bolded can be removed if you dont want your games in a table. I think it makes them behave a little better than just being free. And you can control the background color. You can also change how many games you have. Look at top of the code
ORDER BY RAND()LIMIT20') Change the number to how ever many you want.



<table style="border-color: #000000; border-width: 0px; background-color: #ffffff;" border="0" align="center" width="670">
<tbody>
<tr>
<td>
<?php
echo '<ul>';

$sql = mysql_query("SELECT * FROM ava_games ORDER BY RAND() LIMIT 20");
while($row = mysql_fetch_array($sql))
{
$seo_name = seoname($row['name']);

if ($setting['seo_on'] == 0)
{
$url = 'index.php?task=view&amp;id='.$row['id'];
}
else if ($setting['seo_on'] == 2)
{

$cat_name = mysql_fetch_array(mysql_query("SELECT name FROM ava_cats WHERE id=$row[category_id]"));
$seo_cat_name = seoname($cat_name['name']);
$url = $seo_cat_name.'/'.$row['id'].'/'.$seo_name.$setting['seo_extension'];
}
else
{
$url = 'view/'.$row['id'].'/'.$seo_name.$setting['seo_extension'];
}


if (strlen($row['name']) > $template['module_max_chars'])
{
$name = substr($row['name'], 0, $template['module_max_chars'])."...";
}
else
{

$name = $row['name'];
}
echo '

<a href="'.$setting['site_url'].'/'.$url.'"><img title="'.$row['description'].'" align="absmiddle" src="'.$row['image'].'" width="110" height="100" />
<!--<img src="'.$setting['site_url'].'/games/images/'.$seo_name['image'].'" alt="" class="game_pic_small" />-->
';
}

echo '</ul>';
?>
<td>
</tr>
</tbody>
</table>


Now paste this anywhere you want random games to show;


<?php include ('includes/random_games.php');?>

AnyWay
04-15-2010, 04:25 AM
Ok, thank you very much, it's working!