Jump to content

shreyaskudav

Members
  • Posts

    83
  • Joined

  • Last visited

About shreyaskudav

  • Birthday 06/17/1995

Previous Fields

  • Languages
    HTML,PHP

Contact Methods

  • MSN
    shreyaskudav@hotmail.com

Profile Information

  • Location
    India

shreyaskudav's Achievements

Newbie

Newbie (1/7)

2

Reputation

  1. $i = 1;foreach ($battlepokemon as $key => $value){if($value['opponent_increment'] == $opponent_increment){$value['battle_health'] = 0;echo "Data replaced!";}$i++;} As you said dsonesuk! This code is working properly..only the assignment of '0' to the attr $value['battle_health'] is not working! is the statement correct??
  2. This is how I defined the array: $j = 1;while($j < $i){$battlepokemon[$j] = array('battle_poke' => $battle_poke[$j], 'battle_level' => $battle_level[$j], 'battle_health' => $battle_health[$j]);$j++;} So the structure is something like this: battlepokemon[1]{battle_poke => xxxxbattle_level => 10battle_health => 50}battlepokemon[2]{battle_poke => xxxxbattle_level => 10battle_health => 50}... and so on... Lets say.. I want to replace the value battlepokemon[1] => battle_health(key) from 50 to 100 using foreach().. How should I do that?? I don't want to do it manually like: $val[$key] = 100; or something like that...!
  3. It shouldn't show North & Islands?? I see no where it is been echoed?
  4. Well, I saw this even on facebook in some PHP group!
  5. Yes..got it! Actually the problem was to minor! I don't know why query could not recognize the formatting I did for the variable : "'.$db_id.'" It worked when I removed everything and just used variable: $db_id
  6. Table definitions: CREATE TABLE IF NOT EXISTS `trade` ( `id` int(11) NOT NULL AUTO_INCREMENT, `trade_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `pkmn_id` varchar(50) NOT NULL, `level` int(11) NOT NULL, `exp` int(11) NOT NULL, `health` int(11) NOT NULL, `attack1` int(11) NOT NULL, `attack2` int(11) NOT NULL, `attack3` int(11) NOT NULL, PRIMARY KEY (`id`)) CREATE TABLE IF NOT EXISTS `user_pokemon_db` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `pkmn_id` int(11) NOT NULL, `level` int(11) NOT NULL, `exp` int(11) NOT NULL, `health` int(11) NOT NULL, `attack1` int(11) NOT NULL DEFAULT '11', `attack2` int(11) NOT NULL DEFAULT '53', `attack3` int(11) NOT NULL DEFAULT '90', `team` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`),) These are the 2 tables @davej...! @thescientist.. Actually yess! they are well defined cause, when I checked the query through echo, they were correctly evaluated ! PS: I think the error is in the query..if you see the error displaying... it says.. near '203''' at line 1 while there is nothing like ''' in the query.. AND id = '".$db_id."' ";
  7. $sql = " INSERT INTO trade (trade_id, user_id, pkmn_id, level, exp, health, attack1, attack2, attack3) SELECT (id, user_id, pkmn_id, level, exp, health, attack1, attack2, attack3) FROM user_pokemon_db WHERE user_id = '".$id."' AND id = '".$db_id."' "; mysql_query($sql) or die(mysql_error()); When I run the code, I get this error now You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '203''' at line 1 I know the query is wrong as the error says..I took help from google to check the syntax..and its quiet the same as I have used!What problem is there in the query?
  8. Hahahah!! Great Davej!! Finally working on it for 3 dayss!!! Got it worked (y) I used foreach() ! Cheers!
  9. hey davej! That idea is quiet simple and cool! (y) Didn't thought of it!! (y) But I can store ID value in array? $disabled[$i] ??
  10. Yes! I have already handled the server... the health reduction and other calculations are set..! <script>function disableElement(){var dis = '<?php echo $dis_value; ?>';document.getElementById(dis).disabled=true;}</script> You see the variable $dis_value , passed to the javascript variable when the health of the pokemon is <= 0. This $dis_value will consisting the value, which is also the ID="" of the radio, which is to be disabled! I just want to know the proper format or syntax, that I should use to save the state of disabled radio in cookie so that it maintains it futher...!
  11. There would be 6 radio...each representing a pokemon...which is to be used! so basically all 6 radios would be enabled! Once a pokemon is killed, i.e. health <=0 ..... the corresponding radio will be disabled..! Therefore user cannot use it again, as its killed! So I need to store it in the cookie...!And also there are 5 more pokemons... I will also require to store all those in the cookie.
  12. Well, do you have any good link that will help me out with storing radio in cookie?? or you can give me some idea about I can I use cookie in this case..!
  13. Yaa! I worked on it..! and fortunately got solved! Problem was in id in form: id="dis'.$i.'" I have a question now..can I maintain this disabled radio even after reload?? Coz now it gets disabled but after reload again gets enabled..! I googled it and got something like I have to use localstorage ??!!
  14. This is my radio disabling function. <script>function disableElement(){var dis = '<?php echo $dis_value; ?>';document.getElementById(dis).disabled=true;}</script> And I will call it when the page is loaded! <body onLoad="disableElement()"> And the radio button is displayed through loop..! echo '<form method="post" action="trainingserver.php">';$i = 1;while($i <= $num_rows){echo '<input type="radio" id="dis"'.$i.'"" name="select" value="'.$i.'" />';echo $poke[$i]."<br>";echo 'Level:'.$level[$i]."<br>";echo 'Health:'.$health[$i]."<br>";$i++;}echo '<input type="submit" name="submit" value="Select Pokemon!" />';echo '</form>'; So the radio ids would be like: dis1,dis2 ... dis6 But its not disabling it...! I think its because of the while loop, I used..! what should I do..?
×
×
  • Create New...