asmith Posted November 30, 2007 Share Posted November 30, 2007 $option = array("1" => "aaa","2" => "bbb","3" => "ccc"); $_SESSION[option] = $option; how can i store option values in one of my database fields? (or more than one field) Quote Link to comment Share on other sites More sharing options...
aschk Posted November 30, 2007 Share Posted November 30, 2007 Do you want all those array values in 1 field, or each of those array values in separate fields? If the former, then just implode with a separator and insert. If the latter then you need to know the fields you are after. Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 implode helps, for the latter, how it can be if i have field1 , field2, filed3 on table "fileds" ? Quote Link to comment Share on other sites More sharing options...
aschk Posted November 30, 2007 Share Posted November 30, 2007 You database table would need to have those columns (i.e. field1, field2, field3) then you insert key 1 into field1, key 2 into field2, etc... note : if you are thinking about adding new COLUMNS for each of those array values then slap yourself on the forehead and redo your database design and rethink that you're doing. Quote Link to comment Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 you mean i extract the array then insert each value to each field ? or has specific code or function ? (sorry i didn't quiet get you, but thanks for implode ! ) 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.