Jump to content

shreyaskudav

Members
  • Posts

    83
  • Joined

  • Last visited

Everything posted by shreyaskudav

  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..?
  15. Is it possible to pass javascript variable in getElementbyId()?? This is my radio code: echo '<td><input id="dis1" type="radio" name="select" value="1" /></td>';echo '<td>'.$poke[0]."<br>";echo 'Level:'.$level[0]."<br>";echo 'Health:'.$health[0]."<br></td>"; The below is my javascript code...in which first the id value is stored in PHP cvariable and then stored in javascript and using this javascript variable, I will disable the radio button. ! <script>var dis_value = <?php echo $dis_value; ?>; //$dis_value = dis1document.getElementById("dis_value").disabled=true;</script> But dunno why it seems not to be working?? are there any constraints which I need to follow if I am using a variable in getElementbyID ???
  16. Ohkk I try again! But if you have understood what I actually want to do...! What would benefit me.. jQuery or Ajax?
  17. @davej : I am trying to avoid Ajax..! @justsomeguy : If its possible with javascript.. do you have any example..or any link that would demonstrate it?? so i can understand it better!
  18. coz I am not use to it.. so I will have to study it deep from the beginning....! And I am quiet good in handling PHP! atleast I know it better the Ajax.. And also its not like that..I never tried it..! last time I tired...but it increased my complication
  19. I want to implement the same concept as it is in ajax! like there would be a server, request and response! But I want to use only PHP! not Ajax! Battleserver.php will act as a server and battle.php will be at the client side...! I can send data from battle.php to battleserver.php by using POST method! But I don't want to make user know that data is send to battleserver.php...! It should not appear in the URL! How can I do that! ??
  20. Well its working now! Just changed the datatype from datetime to timestamp!
  21. <?phpsession_start();include 'details.php';$lastvisited = date("Y-m-d");$sql = "UPDATE users SET lastvisited = $lastvisited WHERE id = '.$id.' ";mysql_query($sql);session_destroy();?> The above code is of logout.php! When user logs out.. an entry is made of the time to the database. Datatype of the column is date. But its not working?? Its stored this value in the database: 0000-00-00 What should I do?
  22. I want to reload the page and then what to show the response! And also want to uncheck the radio <input type="radio" value="10" name="attack" onClick="sendid(this.value)"/> Attack 1<input type="radio" value="20" name="attack" onClick="sendid(this.value)"/> Attack 2
  23. Thnks It worked somehow! dunno how?? !
×
×
  • Create New...