Re: mysql_fetch_assoc question

From: Date: Wed, 04 Sep 2002 10:39:34 +0000
Subject: Re: mysql_fetch_assoc question
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-21561@lists.php.net to get a copy of this message
Hey Graeme, > $MemberID = @mysql_query("SELECT ID FROM SiteMember WHERE Username = > '$valid_user'"); > $array = mysql_fetch_assoc($MemberID); > print_r($array); > this will produce: > Array ( [ID] => 3 ) > > All I want is the value 3 so that I can go ahead and insert that into the > Lookup table. > Any ideas how I can just extract this value? I'm also not 100% clear on > what "mysql_fetch_assoc" does, can anyone explain it? mysql_fetch_assoc() takes the response from MySQL (the query resultset) and hands it to PHP as an associative array. This array only consists of one element: $array['ID'] - which in your example has the value 3. So echo $array['ID']; or similar use will give you what you seem to be asking for. Please read the manual: mysql_fetch_assoc() and the whole appendix on MySQL functions array processing and associative arrays Of course if you are resolving the value (3) in order to submit that to another query ("Lookup table"), then you should be looking at relational database methodology and table joins! Regards, =dn

« previous php.db (#21561) next »