Jump to content

[SOLVED] How to move information around help needed.


timecatcher

Recommended Posts

Hey ok heres the script:

 

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

echo("$openHTML");

$gameprice = 5;
$reward = 15;

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>
echo;
if(isset($_GET['act']) == "done"){
if($_GET['guess'] = "lower" && $_GET['real'] = "b"){
echo"Congratulations you answered correctly! You just earned <b>250RC</b>!";
}
else{
echo"Sorry that was incorrect.";
}
echo"
</tr>
</td>
</table>";
die("$closeHTML");
}
echo<<<echo
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 5RC to play the game;
however for each item you guess correctly you will get <b>15RC!</b><br />
echo;
$idquery = mysql_query("SELECT MIN(id), MAX(id) FROM items");
$idrow = mysql_fetch_array($idquery);
$high = $idrow['MAX(id)'] ;
$low = $idrow['MIN(id)'] ;
$rndid = rand($low, $high);
$itemquery = mysql_query("SELECT * FROM items WHERE `id` = $rndid");
$itrow = mysql_fetch_array($itemquery);
$name = $itrow['name'];
$price = $itrow['price'];
$pom = rand(1,2);
//Gives the chance for it being higher or lower rather than staying the same.
$tpc = $price/100*10 ;
//Works percentage. 'Ten Percent something '
$tpcf = number_format($tpc);
//Makes sure its got no decimals.

if($pom < 2){
$nprice = $price+$tpcf ;
}

if($pom > 1){
$nprice = $price-$tpcf ;
}
//Choooses to either add or subtract from the price.

echo<<<echo
<center>
<img src="../images/items/$rndid.png">
<br />
$name
<br />
$nprice
<br />
echo;
if($nprice > $price){
$guess = a ;
} elseif ($nprice < $price){
$guess = b ;
}
echo<<<echo
<a href="/games/pricegs.php?act=done&guess=lower&real=$guess">Lower</a>
</center>
echo;


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

echo("$closeHTML");
?>

 

What im wanting to do is set say $guess to 'a' and if the price is actually lower than the new price give the message welldone (and give points but I can do that at a later date) but so far if the answer is right or wrong they still get the message 'Congratulations' :'(, so im wanting to know what a better way would be to do this (stll in one file if possible.) Im also thinking maybe if I can do it with $_POST it might be better because if they guess that A is right B isn't they will be able to cheat the system, thanks.

 

TC.

you need to set the variables as strings, Meaning, you need to enclose the value within quotes.

 

change this:

if($nprice > $price){
$guess = a ;
} elseif ($nprice < $price){
$guess = b ;
}

 

to this:

if($nprice > $price){
$guess = "a";
} elseif ($nprice < $price){
$guess = "b";
}

 

Regards ACE

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.