Gregoyle Posted March 28, 2011 Share Posted March 28, 2011 This is what i have $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $trading->username . "' ORDER BY `name` ASC"); How can i do this: $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" AND `traded`='0' . $trading->username . "' ORDER BY `name` ASC"); I know its not as simple as just adding AND `traded`='0' cause i tried that and i just got this Parse error: syntax error, unexpected '=' in /home/tpkrpgn1/public_html/trade5.php on line 57 MySQL table (in case you need to know it?) (`id`, `trainer`, `gender`, `name`, `party1`, `party2`, `party3`, `party4`, `party5`, `party6`, `level`, `exp`, `hp`, `totalhp`, `att`, `def`, `box`, `days`, `battle_wins`, `battle_losses`, `move1`, `move2`, `move3`, `move4`, `attbon`, `defbon`, `totalexp`, `sold`, `traded`, `item`, `soldtrainer`) Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/ Share on other sites More sharing options...
trq Posted March 28, 2011 Share Posted March 28, 2011 I know its not as simple as just adding AND `traded`='0' cause i tried that and i just got this Obviously, you need to add it within the right place. $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box` = 1 AND `trainer` = '" . $trading->username . "' AND `traded` = 0 ORDER BY `name` ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193433 Share on other sites More sharing options...
Maq Posted March 28, 2011 Share Posted March 28, 2011 You mixed up the conditionals, try: $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `traded`='0' AND`trainer`='" . $trading->username . "' ORDER BY `name` ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193434 Share on other sites More sharing options...
jcbones Posted March 28, 2011 Share Posted March 28, 2011 Yes, it is a simple as adding "AND traded='0' ". Parse errors do NOT come from bad MySQL queries, they come from BAD PHP code. Don't make the mistake of thinking they are the same engine, or language. $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='{$trading->username}' AND `traded`='0' ORDER BY `name` ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193435 Share on other sites More sharing options...
Maq Posted March 28, 2011 Share Posted March 28, 2011 Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193436 Share on other sites More sharing options...
jcbones Posted March 28, 2011 Share Posted March 28, 2011 <3 when the same answer gets posted 3 times In 55 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193439 Share on other sites More sharing options...
Gregoyle Posted March 28, 2011 Author Share Posted March 28, 2011 Fortunately that fixed half of the issue, Why only half? Cause it opened another one Now when i run $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='{$trading->username}' AND `traded`='0' ORDER BY `name` ASC"); It doesn't display my list anymore, Just the other persons list (It does EXACTLY what i wanted just cant see my list anymore) So basically for the other persons list its like this $traderss1=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='{$trading->username}' AND `traded`='0' ORDER BY `name` ASC"); And the list maker <td class="w50"><p class="center"><?=$trading->username?>'s Pokémon<br /><select name="othertrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($tradert=mysql_fetch_object($traderss1)){?><option value="<?=$tradert->id?>"><?=$tradert->name?> <?=$tradert->gender?> (Level:<?=$tradert->level?>)</option><?}?></select></p></td></table> And for my list (As you can see i had to re-instate the old code :\ $owntraderss2=mysql_query("SELECT * FROM `poke_owned` WHERE `box`='1' AND `trainer`='" . $user->username . "' ORDER BY `name` ASC"); <form action="/trade5.php?a=<?=$_GET['q']?>" method="POST"><table class="w100"><tr><td class="w50"><p class="center">Your Pokémon<br /><select name="mytrade[]" multiple="multiple" size="20"><option value="niks" selected>(No Pokémon)</option><?while($owntradert=mysql_fetch_object($owntraderss2)){?><option value="<?=$owntradert->id?>"><?=$owntradert->name?> <?=$owntradert->gender?> (Level:<?=$owntradert->level?>)</option><?}?></select></p></td> So is there any way to make it where BOTH lists can use the same thing? Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193458 Share on other sites More sharing options...
jcbones Posted March 28, 2011 Share Posted March 28, 2011 Anything is possible, but we will need to see how your tables are made. Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193460 Share on other sites More sharing options...
Gregoyle Posted March 28, 2011 Author Share Posted March 28, 2011 My SQL Tables? Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193462 Share on other sites More sharing options...
Gregoyle Posted March 28, 2011 Author Share Posted March 28, 2011 Never mind i figured it out, Only thanks to you fine people. Thanks alot. ~Greg~ Quote Link to comment https://forums.phpfreaks.com/topic/231989-php-mysql_query-select-from-quick-question/#findComment-1193475 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.