i have posted this be for but i have re posted cus i relay wanna get this done to night
i have a rpg a pokemon rpg the problem is the user has 6 main pokemon that they can use but i wanna make a box ( a computer or something 0
so when they don't wanna use them 6 they can put them into user_box and get different 1s out
the problem i have is the 6 slots are stored in sessions has well has the db
i have got some 1 to make me a sell page which does the same job has what i want the user box to do
this is my new code i just coded up
user_box_send.php
CODE
?php
// show the user their pokemon
include_once('pokemon_level.php');
// end file include
?>
</div>
<div class="mid_box">
<div class="mid_box_title">Want to Send your pokemon To Your Box ?</div>
<p>
<script>
$(document).ready(function(){
$("select#pokeSLOT").change(function () {
$("button#Submit_But").text("Sell " + $("select#pokeSLOT option:selected").text());
});
$("button#Submit_But").click(function () {
var theSlot = $("select#pokeSLOT option:selected").val();
var sellPokemon = $("select#pokeSLOT option:selected").text();
if (theSlot == "" || sellPrice == "") { alert("Required fields were left blank."); return false;}
confMes = confirm("You are about to attempt to send " + send + " for " + sellPrice + ". Are you sure?");
if (confMes) {
$.post("/phpDocs/User_box.php", {
mode: "sendPokemon",
pokemonName: sellPokemon,
sellPrice: sellPrice,
User: "<?php echo $_SESSION['username']; ?>",
pokemonSlot: theSlot
},
function(data){
alert(data);
window.location.href="/BuyPokemon.php";
}
);
return false;
} else {
alert("CANCELLED");
return false;
}
});
});
</script>
Note: This is just been made so There Mite Be Some Errors <br />
</p>
<form>
<label>What slot do you want to Send To Box ?</label>
<select name="pokeSLOT" id="pokeSLOT" style="width:150px;padding-left:5px;">
<option value=""></option>
<?php
for ($x=1;$x<7;$x++) {
if (isset($pokemon->{pok . $x}['pokeNAME'])) {
echo '<option value="'.$x.'">'.$pokemon->{pok . $x}['pokeNAME'].'</option>';
} else {
echo '<option value=""></option>';
}
}
?>
</select>
<br/>
<br/>
<label></label>
<br/>
<br/>
<button name="submit" type="submit" id="Submit_But">send</button>
</form>
<div style="clear:both;"></div>
</div>
</div>
</div>
that lets the user pick what slot they want to sell but i was gonna change it to add to box but then i looked at the main code of it
this is what ive changed it to so it sends the pokemon to user_box instead of poke_sell
User_box.php
CODE
function execsendPokemon() {
$sellName = $_POST['pokemonName'];
$User = $_POST['User'];
$slot = $_POST['pokemonSlot'];
$info = "SELECT T1.pok".$slot."LV, T1.pok".$slot."EXP, T2.pokePIC FROM user_pokemon as T1
INNER JOIN pokemon as T2 ON (T2.pokeNAME = '".$sellName."')
WHERE userNAME = '".$User."' LIMIT 1";
$inf = mysql_query($info) or ($this->errorHandler(mysql_error(). ' INFO'));
$in = mysql_fetch_array($inf);
$level = $in['pok'.$slot.'LV'];
$exp = $in['pok'.$slot.'EXP'];
$pic = $in['pokePIC'];
$q = "INSERT INTO user_box
(username, pokemon, pokePIC, time_stamp, level, exp)
VALUES
( '".$User."', '".$sellName."', '".$pic."', '".time()."', '".$level."', '".$exp."')";
$r = mysql_query($q) or ($this->errorHandler(mysql_error(). ' INSERT'));
if ($r) {
$this->execRemoveFromUser($slot,$sellUser);
echo "You have Added $sellName.";
} else {
echo "An error has occured in the selling of $sellName please try again later";
}
}
function execRemoveFromUser($slot,$user) {
$q = "UPDATE user_pokemon SET
pok".$slot." = '0',
pok".$slot."LV = '0',
pok".$slot."EXP = '0'
WHERE userNAME = '".$user."'";
$r = mysql_query($q) or ($this->errorHandler(mysql_error(). ' Delete'));
}
can any 1 see why it ent working ?
This post has been edited by nick1200: 3 Jul, 2009 - 06:09 PM