richiec Posted July 30, 2007 Share Posted July 30, 2007 Hey guys and girls, im stuck and could use a little help.. if you go here you will see a list of items: http://fearedwarlords.dks-gfx.com/items/items.php What i would like to do is at the top where it has the button "gem" when clicked it changes the stats of all the items to a set % + Heres the code i have right now: //gets the info from db// $stock = mysql_result($result,$i,"stock"); $name = mysql_result($result,$i,"name"); $hitpoints=mysql_result($result,$i,"hitpoints"); $attack=mysql_result($result,$i,"attack"); $rage=mysql_result($result,$i,"rage"); $maxrage=mysql_result($result,$i,"maxrage"); $exp=mysql_result($result,$i,"exp"); $critical=mysql_result($result,$i,"critical"); $rampage=mysql_result($result,$i,"rampage"); $block=mysql_result($result,$i,"block"); $image=mysql_result($result,$i,"image"); //echos them all// echo " <tbody><tr> <td colspan=\"2\" style=\"font-weight: bold; height: 20px; font-size: 10pt; color: rgb(204, 204, 204);\" align=\"left\">$name x $stock</td> </tr> <tr> <td style=\"padding: 2px; font-family: Verdana; font-weight: bold; font-size: 7pt; color: rgb(255, 255, 255);\" align=\"left\" valign=\"top\"> <br> $hitpoints Hit points<br>$attack Attack<br>$rage Rage per turn<br>$maxrage Max Rage<br>$exp Experience per turn <br>$rampage % Rampage<br>$critical % Critical hit<br>$block % Block <br><br> </td> <td style=\"width: 80px; font-family: Verdana; font-size: 7pt; color: rgb(255, 255, 255);\" align=\"center\" valign=\"top\"> <img src=\"$image\" style=\"border: 1px solid rgb(102, 102, 102); margin: 2px;\"></a><br> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"><br> <img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><br></td> </tr> "; What i was thinking was something like... /// if ($_REQUEST["Submit"] != NULL){ //// $hitpoints = ($hitpoints * 74%); $attack = ($attack * 92%); $rage = ($rage * 75%); $exp = ($exp * 75%); $maxrage = ($maxrage * 74%); $rampage = ($rampage * 83%); I know thats not right, and im abit of a noobie but any ideas on how i could do what im wanting to do? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 30, 2007 Share Posted July 30, 2007 Try doing it like: $hitpoints = $hitpoints/100*74; Edit: Also, you might only want whole numbers. If so, use the round() function: $hitpoints = round($hitpoints/100*74); Quote Link to comment Share on other sites More sharing options...
Barand Posted July 30, 2007 Share Posted July 30, 2007 or $hitpoints = ($hitpoints * 0.74); Quote Link to comment Share on other sites More sharing options...
richiec Posted July 30, 2007 Author Share Posted July 30, 2007 where would i put it, because if i put it before i echo it all, it displays no items (both before and after pressing the gem button) and if i put it after it echos it all, it doesnt display any changes after pressing Quote Link to comment Share on other sites More sharing options...
richiec Posted July 30, 2007 Author Share Posted July 30, 2007 ok i got that working, kind of it doesnt work out the % + for the gems right but i can mess with that once i get it fully working.. However the other thing wrong with it now, is that after it gets the info for the first item it breaks the table and displays all of the others outside of the table http://fearedwarlords.dks-gfx.com/items/items.php if you look there you will see what i mean, any ideas? Quote Link to comment Share on other sites More sharing options...
Barand Posted July 30, 2007 Share Posted July 30, 2007 Sounds like the table isn't constructed correctly and some data is outside td /td tags Quote Link to comment Share on other sites More sharing options...
richiec Posted July 30, 2007 Author Share Posted July 30, 2007 it worked fine before i added the if.. else.. into it.. can you only have one echo using the if, else command? This is the echo code... if ($_REQUEST["gem"] != NULL){ //echos the gemmed stats// $i++; echo " <tbody><tr> <td colspan=\"2\" style=\"font-weight: bold; height: 20px; font-size: 10pt; color: rgb(204, 204, 204);\" align=\"left\">$name x $stock</td> </tr> <tr> <td style=\"padding: 2px; font-family: Verdana; font-weight: bold; font-size: 7pt; color: rgb(255, 255, 255);\" align=\"left\" valign=\"top\"> <br> $hitpoints2 Hit points<br>$attack2 Attack<br>$rage2 Rage per turn<br>$maxrage2 Max Rage<br>$exp2 Experience per turn <br>$rampage % Rampage<br>$critical % Critical hit<br>$block % Block <br><br> </td> <td style=\"width: 80px; font-family: Verdana; font-size: 7pt; color: rgb(255, 255, 255);\" align=\"center\" valign=\"top\"> <img src=\"$image\" style=\"border: 1px solid rgb(102, 102, 102); margin: 2px;\"></a><br> <img src=\"http://fearedwarlords.dks-gfx.com/images/gem_green.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gem_blue.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gem_red.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gem_white.jpg\"><br> <img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><br></td> </tr> "; echo '</tbody></table></td></tr></tbody></table></center></div>'; } else { //echos the ungemmed stats// $i++; echo " <tbody><tr> <td colspan=\"2\" style=\"font-weight: bold; height: 20px; font-size: 10pt; color: rgb(204, 204, 204);\" align=\"left\">$name x $stock</td> </tr> <tr> <td style=\"padding: 2px; font-family: Verdana; font-weight: bold; font-size: 7pt; color: rgb(255, 255, 255);\" align=\"left\" valign=\"top\"> <br> $hitpoints Hit points<br>$attack Attack<br>$rage Rage per turn<br>$maxrage Max Rage<br>$exp Experience per turn <br>$rampage % Rampage<br>$critical % Critical hit<br>$block % Block <br><br> </td> <td style=\"width: 80px; font-family: Verdana; font-size: 7pt; color: rgb(255, 255, 255);\" align=\"center\" valign=\"top\"> <img src=\"$image\" style=\"border: 1px solid rgb(102, 102, 102); margin: 2px;\"></a><br> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"> <img src=\"http://fearedwarlords.dks-gfx.com/images/gemslot.jpg\"><br> <img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><img src=\"http://fearedwarlords.dks-gfx.com/images/augslot.jpg\"><br></td> </tr> "; echo '</tbody></table></td></tr></tbody></table></center></div>'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.