xxtobirichter Posted December 16, 2007 Share Posted December 16, 2007 Hello, i am experimenting with the following. $answerpick = mysql_query("SELECT id FROM answer order by rand() limit 1"); Receive array from mysql. Now i would like to store the value in a variable to work with it throughout the script, is that possible? I ve tried to { print "The answer is".$test{'id'}." <br>"; } and it prints the id...so far so good, but now i would like to perform the following $choicepick= mysql_query("SELECT cid FROM choice where cid<>$id"); $id should refer to the id retrieved in the first querry. I tried to define $id = ".test$('id')." but that appears to be impossible, I ve tried to find info on the net but couldnt. If this approach doesnt work is there another way to store array information in a variable or to execute the $choicepick querry with regard to retrieved information from $answerpick? Thanks for any input Regards Tobi Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 16, 2007 Share Posted December 16, 2007 $choicepick= mysql_query("SELECT cid FROM choice where cid<>'{$test['id']}'"); $choicepick= mysql_query("SELECT cid FROM choice where cid!='{$test['id']}'"); Im not sure if <> is a valid mysql operator, so my second one I know is where I use != but give that a try. Quote Link to comment Share on other sites More sharing options...
xxtobirichter Posted December 16, 2007 Author Share Posted December 16, 2007 Yes great it worked...<> works as well..thx a lot!!! it seems so obvious when u cant define the variable use the initial one... Thanks for opening my eyes!!! Quote Link to comment Share on other sites More sharing options...
corbin Posted December 16, 2007 Share Posted December 16, 2007 $id = $test['id']; $choicepick= mysql_query("SELECT cid FROM choice where cid<>'{$id}'"); //should work fine Also, <> is like saying is less than or greater than.... So, the numbers less than 1 and greater than one would be all numbers that are not one, so it's like saying not equal to 1. <> is valid in SQL (MySQL/MSSQL I know for sure), PHP, and I think some of the lower level languages might even use it, but I'm not sure. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 16, 2007 Share Posted December 16, 2007 Visual Basic uses <> and it means "doesn't equal" So that is where I got the idea Quote Link to comment 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.