Jump to content

Price Guess Game Help Needed


timecatcher

Recommended Posts

Hey im trying to improve my PHP skills on a virtual pet site. Im making a game at the moment and the idea is that it picks a random 'item' from the items table and then randomises the price to + or - 1000 each side so for example if the item was an apple you would see the picture then underneath would be a randomised prise somewhere + or - 1000 the original price...so it could originally cost 1234 and now it displays 1567 there would then be too options saying higher or lower and if its correct they get points if not they lose. Here is the script so far:

 

<?php
include("../config.php");

echo("$openHTML");
if($userPlays['pricegs'] == 20){
$time['24'] = time()-86400;

if($userPlays['pricegs2'] < $time['24']){
mysql_query("UPDATE usersPlays SET pricegs='0', pricegs2='0' WHERE userid='$user[id]'") or die(mysql_error());
header("location: $config[siteURL]/games/pricegs.php");
}

echo<<<echo
<table width="60%" align="center" cellspacing="2" cellpadding="2" style="border: 1px solid #000000;">
<tr>
<td background="$config[siteURL]/layout/tabletop.png" align="center" height="20" style="border: 1px solid #215c06;">
<font color="#FFFFFF">Price Guess</font>
</td>
</tr>
<tr>
<td align="center">
You have reached <b>20</b> game plays today.<br>
You can play again tomorrow.</center>
</td>
</tr>
</table>
echo;

die("$closeHTML");
}
$gameprice = 100;
$reward = 250;

echo<<<echo
<table width="60%" align="center" cellspacing="2" cellpadding="2" style="border: 1px solid #000000;">
<tr>
<td background="$config[siteURL]/layout/tabletop.png" align="center" height="20" style="border: 1px solid #215c06;">
<font color="#FFFFFF">Price Guess</font>
</td>
</tr>
<tr>
<td>
Think you know Ryupets items well enough?
Try to guess whether the price for the item is higher or lower than the real restock price! 
It costs 100RC to play the game;
however if you win you will get 250RC!<br />
<center>Only <b>20</b> tries a day however so think carefully.</center><br />
echo;
$itemquery = mysql_query("SELECT * FROM items");
$iftch = mysql_fetch_array($itemquery);
$test1 = 100 ;
$test2 = 1 ;
$test = rand($test1, $test2);

echo<<<echo
$test
echo;

echo<<<echo
</td>
</tr>
</table>
echo;

echo("$closeHTML");
?>

 

My main issue at the moment is getting my head around using rand and the MYSQL bits...if im wanting it to choose a random itemid from the table but not choose like 5007 or something which doesn't exist how can I be specific to make sure it chooses a number only from the amount of itemids in the table. Thanks.

 

TC. (Hope I explained ok.)

Link to comment
https://forums.phpfreaks.com/topic/146250-price-guess-game-help-needed/
Share on other sites

Alright I have got it a little further along but now Im wanting to do it so it takes the initial 'price' and adds or minus's a number up to and including 1000, however Im not too sure how to do this. The random picture/id thing is done now thanks.

 

TC.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.