I show all there monsters and the other users monsters on the 1 page but when they pick what they want and what there offering for the monsters it will not add the info into the db...
So i have a page were they have to enter the users username they want to trade with.
<form name="input" action="tradedo.php" method="get"> Username: <input type="text" name="username_trade" /> <input type="submit" value="Submit" /> </form>
Then on tradedo.php there monsters are shown and the others users monsters are grab and they can pick what they want and what there offering for them...
session_start();
mysql_connect("localhost", "blah", "");
mysql_select_db("");
$username_trade = $_POST['username_trade'];
$_SESSION['username_trade'] = $username_trade ;
echo "You put in id ". $username_trade . ".<br />";
?>
</p>
<p> </p>
<p><span class="mid_box">
<?php
// get and display userbox
$q = "SELECT id,pokemon,exp,level FROM user_pokemon WHERE belongsto='". $_SESSION['username_trade']."'";
$r = mysql_query($q);
if (mysql_num_rows($r) <= 0) {
echo "You have no current pokemon stored";
}
?>
</span></p>
<p> </p>
<p>
<?php
echo "<form action='tradestore.php' method='POST'>";
while ( $v = mysql_fetch_object( $r ) )
{
echo "<label><input type='checkbox' name='pokemon[]' value='$v->dbid'/> They have a $v->pokemon </label><br/>";
echo "<label> Level $v->level </label><br/>";
}
echo "<input type='hidden' name='user' value='$username_trade'/>";
echo "<input type='submit' value='Check!!'/>";
?>
</p>
<p><strong>Pick what you want two offer for the pokemon </strong></p>
<p>
<?php
// get and display userbox
$q = "SELECT id,pokemon,exp,level FROM user_pokemon WHERE belongsto='". $_SESSION['username']."'";
$t = mysql_query($q);
if (mysql_num_rows($t) <= 0) {
echo "You have no current pokemon stored";
}
?>
</p>
<p>
<?php
echo "<form action='test_process.php' method='POST'>";
while ( $v = mysql_fetch_object( $t ) )
{
echo "<label><input type='checkbox' name='pokemonin[]' value='$v->dbid'/> I have a $v->pokemon</label><br/>";
echo "<label> Level $v->level </label><br/>";
}
echo "<input type='hidden' name='userin' value='$username'/>";
echo "</form>";
It works great .... It shows all the monsters and everything is great but now i need to insert them and here is the insert page
$pokemon = $_POST['pokemon'];
$pokemonin = $_POST['pokemonin'];
$meid = $_SESSION['username'];
$toid = $_POST['user'];
$dbid = array();
$dbid2 = array();
foreach ( $pokemon as $poke )
{ $dbid['pokemon'][] = $poke;
}
foreach ( $pokemonin as $poke2 )
{ $dbid2['pokemonin'][] = $poke2;
}
srand ((double) microtime( )*1000000);
$random_number = rand( );
echo "$random_number";
mysql_query("INSERT INTO trade (trade_id, trade_to, trade_from, trade_pokeid, trade_mypokeid)
VALUES ('$random_number','".$toid."', '".$meid."', '".$dbid['pokemon']."', '".$dbid2['pokemonin']."');") or die("Error: ". mysql_error());
In my db im getting
trade_id = 1977949793(works) trade_to = trade_from = admin (works) trade_pokeid = Array ( no monster ids ???) trade_mypokeid = Array( no monster ids ???)
Be for the script use to insert the monster id has 1,4,5,7 then id grab them and show them on a trade accept page.. but not its just adding Array and not even grabing the trade_to i have tried to explain the best i can.
And the db connect i have edited out .....
I have also tried this for the update page
session_start();
mysql_connect("localhost", "blahhhhhhhhhhh", "");
mysql_select_db("");
$pokemon = $_POST['pokemon'];
$pokemonin = $_POST['pokemonin'];
$meid = $_SESSION['username'];
$toid = $_POST['user'];
$dbid = array();
$dbid2 = array();
foreach ( $pokemon as $poke )
{
$pokemoninArray = each($pokemonin);
$pokemonin = $pokemoninArray[0];
srand ((double) microtime( )*1000000);
$random_number = rand( );
echo "$random_number";
mysql_query("INSERT INTO trade (trade_id, trade_to, trade_from, trade_pokeid, trade_mypokeid)
VALUES ('$random_number','".$toid."', '".$meid."', '".$poke."', '".$pokemonin."');") or die("Error: ". mysql_error());
}
echo"Done";
But still the insert does not work..
This post has been edited by rpgmaker: 06 February 2012 - 10:19 AM

New Topic/Question
Reply



MultiQuote






|