Jump to content
MakeWebGames

Awards help


skooda

Recommended Posts

Hey I was wondering if someone could start this off maybe 2 example how to do it.Well I been trying to add images to my honor awards and to show it on the users profie once they have completed it wil show on their profile.

 

print "</table>
<table cellspacing=1 class='table' width='100%'>
<tr><th colspan=3><h6>Awards</h6></th></tr>";
if($r['honors'] == 14){$crm1 = "<img src='/awards/theft1.png' alt='The Sneak Thief Award' title='The Sneak Thief Award' border='1'>";}
print "<tr><td colspan=5><center>No Awards</center></td>";

print "</table>";

 

That's what I was doing but it didnt seem to work heres the honor awards exchange that i was going off of aswell.

 

<?php
include "globals.php";
if(!$_GET['spend'])
{
print "<br />
<table width=100% cellspacing=1>
<tr><th colspan=3><h6>Honor Award Exchange Center</h6></th></tr>
<tr><td colspan=3 align=center>You have <b>{$ir['honors']}</b> honors.<br />
What would you like to spend your honors on?</th></tr>
<tr><th>Trade For</th><th>Info</th><th>Trade</th></tr>
<tr align=center><td>Labour</td><td>500 Labour Per Honor</td><td><a href='HonorExchange.php?spend=labour'>Trade</a></td></tr>
<tr align=center><td>Strength</td><td>500 Strength Per Honor</td><td><a href='HonorExchange.php?spend=strength'>Trade</a></td></tr>
<tr align=center><td>Agility</td><td>500 Agility Per Honor</td><td><a href='HonorExchange.php?spend=agility'>Trade</a></td></tr>
<tr align=center><td>Guard</td><td>500 Defense Per Honor</td><td><a href='HonorExchange.php?spend=guard'>Trade</a></td></tr>
<tr align=center><td>IQ</td><td>100 IQ Per Honor</td><td><a href='HonorExchange.php?spend=IQ'>Trade</a></td></tr>
<tr align=center><td>Money</td><td>\$750 Per Honor</td><td><a href='HonorExchange.php?spend=money'>Trade</a></td></tr>
<tr align=center><td>Crystals</td><td>50 Per Honor</td><td><a href='HonorExchange.php?spend=crystals'>Trade</a></td></tr>
<tr align=center><td>Points</td><td>10 Per Honor</td><td><a href='HonorExchange.php?spend=points'>Trade</a></td></tr>
<tr align=center><td>BioHazards Weapon Of Torture (5000 power)</td><td>Trade 100 honors</td><td><a href='HonorExchange.php?spend=biohazardgun'>Trade</a></td></tr>
<tr align=center><td>BioHazards Armor (5000 armor)</td><td>Trade 100 honors</td><td><a href='HonorExchange.php?spend=biohazardarmor'>Trade</a></td></tr>
</table>
";
}
else
{
if($_GET['spend'] == 'biohazardgun')
{
if($ir['honors'] < 100)
{
print "Error, you do not have enough honors.<br />
<a href='HonorExchange.php'>Back</a>";
}
else
{
$db->query("UPDATE users SET honors=honors-100 WHERE userid=$userid");
item_add($ir['userid'], 31, 1);
print "You traded 100 honors for BioHazards Weapon Of Torture.";
}
}
else if($_GET['spend'] == 'biohazardarmor')
{
if($ir['honors'] < 100)
{
print "Error, you do not have enough honors.<br />
<a href='HonorExchange.php'>Back</a>";
}
else
{
$db->query("UPDATE users SET honors=honors-100 WHERE userid=$userid");
item_add($ir['userid'], 32, 1);
print "You traded 100 honors for an BioHazards Armor.";
}
}
else if($_GET['spend'] == 'IQ')
{
print "Type in the amount of honors you want to swap for IQ.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = 100 IQ.<form action='HonorExchange.php?spend=IQ2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'IQ2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=IQ'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*100;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']} WHERE userid=$userid");
$db->query("UPDATE userstats SET IQ=IQ+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for $iqgain IQ.";
}
}
else if($_GET['spend'] == 'crystals')
{
print "Type in the amount of honors you want to trade.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = 50 crystals.<form action='HonorExchange.php?spend=crystals2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'crystals2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=crystals'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*50;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']},crystals=crystals+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for ".number_format($iqgain)." crystals.";
}
}
else if($_GET['spend'] == 'points')
{
print "Type in the amount of honors you want to trade.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = 10 points.<form action='HonorExchange.php?spend=points2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'points2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=points'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*10;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']},points=points+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for ".number_format($iqgain)." points.";
}
}
else if($_GET['spend'] == 'strength')
{
print "Type in the amount of honors you want to swap for strength.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = 500 strength.<form action='HonorExchange.php?spend=strength2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'strength2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=money'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*500;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']} WHERE userid=$userid");
$db->query("UPDATE userstats SET strength=strength+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for ".number_format($iqgain)." strength.";
}
}
else if($_GET['spend'] == 'agility')
{
print "Type in the amount of honors you want to swap for agility.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = 500 agility.<form action='HonorExchange.php?spend=agility2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'agility2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=money'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*500;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']} WHERE userid=$userid");
$db->query("UPDATE userstats SET agility=agility+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for ".number_format($iqgain)." agility.";
}
}
else if($_GET['spend'] == 'guard')
{
print "Type in the amount of honors you want to swap for guard.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = 500 guard.<form action='HonorExchange.php?spend=guard2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'guard2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=money'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*500;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']} WHERE userid=$userid");
$db->query("UPDATE userstats SET guard=guard+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for ".number_format($iqgain)." guard.";
}
}
else if($_GET['spend'] == 'labour')
{
print "Type in the amount of honors you want to swap for labour.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = 500 labour.<form action='HonorExchange.php?spend=labour2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'labour2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=money'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*500;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']} WHERE userid=$userid");
$db->query("UPDATE userstats SET labour=labour+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for ".number_format($iqgain)." labour.";
}
}
else if($_GET['spend'] == 'money')
{
print "Type in the amount of honors you want to swap for money.<br />
You have <b>{$ir['honors']}</b> honors.<br />
One Honor = \$750.<form action='HonorExchange.php?spend=money2' method='post'><input type='text' name='honors' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'money2')
{
$_POST['honors']=(int) $_POST['honors'];
if($_POST['honors'] <= 0 || $_POST['honors'] > $ir['honors'])
{
print "Error, you either do not have enough honors or did not fill out the form.<br />
<a href='HonorExchange.php?spend=money'>Back</a>";
}
else
{
$iqgain=$_POST['honors']*750;
$db->query("UPDATE users SET honors=honors-{$_POST['honors']},money=money+$iqgain WHERE userid=$userid");
print "You traded {$_POST['honors']} honors for \$".number_format($iqgain).".";
}
}
}

$h->endpage();
?>
Link to comment
Share on other sites

The if was going to show to the awards they had which mean only the awards they have won will only show on their profile which other users can view.

EX-

if($ir['userid'] != 1)

{

only user 1 can be their.I dont really have any exp with else aswell
Link to comment
Share on other sites

You're not printing the "crm1" variable.

if($r['honors'] == 14){$crm1 = "<img src='/awards/theft1.png' alt='The Sneak Thief Award' title='The Sneak Thief Award' border='1'>";}

But regardless of whether this conditon passes, you're still printing the "No Awards".

if ( condition ) { 
   echo '...';
} else {
   echo ' No Awards';
}

But even then, you do not have anything that relates to what 'awards' the user has chosen to spend their points on.

A few pointers below;

/*
Your award choose/spend file.
*/

//When chosen an award.
$awardChosen = 1; //Clearly it'll be the award's ID.

$newAwardList = (trim($ir['awardsChosen']) == '') ? $awardsChosen : $ir['awardsChosen'].','.$awardsChosen;
//Update a db field (you know how to do this no? `field` = $newAwardList).



/*
Your display file.
Now displaying you could have something like.
*/
$awardImages = array (
   1 => 'image1.png', // x => y ((x = awards id, y = path/to/image))
   2 => 'image2.php',
   3 => 'image3.php',
);


if (trim ($r['awardsChosen']) == '') {
   echo '<p>No awards</p>';
} else {
   if (strpos($r['awardsChosen'], ',') === false) {
       //Only one award.
       echo (array_key_exists($r['awardsChosen'], $awardImages)) ? $awardImages[$r['awardsChosen']] : '';
   } else {
       //More than one award (or not, maybe a rouge comma, but doesn't matter to much).
       $awards = explode(',', $r['awardsChosen']);
       foreach ($awards as $award) {
           echo (array_key_exists($award, $awardImages)) ? $awardImages[$award] : '';
       }
   }
}

I am lazy, I have not tested it, it may not even be pratical but it's an idea.

Edited by Djkanna
Bah I am to tired for this, stupid $r/$ir
Link to comment
Share on other sites

You're not printing the "crm1" variable.
if($r['honors'] == 14){$crm1 = "<img src='/awards/theft1.png' alt='The Sneak Thief Award' title='The Sneak Thief Award' border='1'>";}

But regardless of whether this conditon passes, you're still printing the "No Awards".

if ( condition ) { 
   echo '...';
} else {
   echo ' No Awards';
}

But even then, you do not have anything that relates to what 'awards' the user has chosen to spend their points on.

A few pointers below;

/*
Your award choose/spend file.
*/

//When chosen an award.
$awardChosen = 1; //Clearly it'll be the award's ID.

$newAwardList = (trim($ir['awardsChosen']) == '') ? $awardsChosen : $ir['awardsChosen'].','.$awardsChosen;
//Update a db field (you know how to do this no? `field` = $newAwardList).



/*
Your display file.
Now displaying you could have something like.
*/
$awardImages = array (
   1 => 'image1.png', // x => y ((x = awards id, y = path/to/image))
   2 => 'image2.php',
   3 => 'image3.php',
);


if (trim ($r['awardsChosen']) == '') {
   echo '<p>No awards</p>';
} else {
   if (strpos($r['awardsChosen'], ',') === false) {
       //Only one award.
       echo (array_key_exists($r['awardsChosen'], $awardImages)) ? $awardImages[$r['awardsChosen']] : '';
   } else {
       //More than one award (or not, maybe a rouge comma, but doesn't matter to much).
       $awards = explode(',', $r['awardsChosen']);
       foreach ($awards as $award) {
           echo (array_key_exists($award, $awardImages)) ? $awardImages[$award] : '';
       }
   }
}

 

I am lazy, I have not tested it, it may not even be pratical but it's an idea.

No dont work

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...