mysql - How can i create arrays from a query in php -


In my data base I have a table "option" in which my site includes options like title, language and so on.

I want to load all these options and store it in an array query database.

This code works manually

  $ option = array ("title" = & gt; "site title", "option 2" => gt; ; "Option 2 value"); Resonance $ option [title];  

But when I create a query ...

  $ query_options = mysql_query ("select option") ;; While ($ data_options = mysql_fetch_row ($ query_options)) {$ option = array ($ data_options [1] = & gt; $ data_options [2]); } Echo $ option [title]; 

This does not work.

Hope you can help me.

Thank you

mysql_fetch_row () Allows access to the column: $ option [0] or $ option [1].

Instead of using mysql_fetch_array () you can access data with $ options ["title"] for example. Using column names.

Look at the doctor

PS - Do not forget the title between the quotation marks!


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -