0

I am fetching some records from database, result of my query returns some values like:

Domain:

Proxy:

Port

Server_Mode:

Now I have a ini file which has these parameters whose value will be empty, So when user edits a file for first time I fetch these records from database and i want to put this according to file parameters.

What I mean is the .ini file will be something like this:

[INIDetails]
SipUserName = 
Password = 
Domain = 
Proxy = 
Port = 
SipAuthName = 
DisplayName = 
ServerMode = 

Now I want to put the values from database against each parameter. How do I do this?

In my view I Do :

if(empty($file_data))
        {   

            echo form_input($value_param, set_value('$value_param',$pbx_data));
        }
        else
        {
            echo form_input($value_param, set_value($value_param, $parameters[$type][$value_param]),'readonly');
        }

Now the result of array from my query is:= $pbx_params And in that array i have domain,proxy,port,server_mode. HOw to write thier values to file ? I guess I have to loop through the values from database and check it with .ini parameter if they match then put the value from db of that row

Rajan
  • 2,427
  • 10
  • 51
  • 111
  • @golez its not at all duplicate i want to print the db values according to parameters – Rajan Apr 13 '16 at 07:16
  • I thought your question was *"HOw to write thier values to file ? "* [sic] That question shows exactly how to read an inifile into an array, optionally populate it with values (from a database in your case) and write the inifile back to disk. – GolezTrol Apr 13 '16 at 07:24
  • Noo I Know how to write the values to ini file but i want to match the parameter against the value then will write the file accordingly – Rajan Apr 13 '16 at 07:25
  • So you want to know how to put a value in an array? – GolezTrol Apr 13 '16 at 07:26
  • I have an array of values from database, and i have some parameters in the file so i want to put the value from database against that parameter, like from db i will get domain=192.158.50.55",proxy="8080" and in file i will have a parameter called domain= so i want to put that 192.158.50.55 against the domain param – Rajan Apr 13 '16 at 07:28
  • @GolezTrol how do i check the array's element against the file parameter? – Rajan Apr 13 '16 at 08:00
  • like $value_param is the parameter from file and $pbx_params is the array i receive from database – Rajan Apr 13 '16 at 08:01
  • Forget about files and databases. You read the inifile in an array, you read the database values into an array (or normal variables). Then it's just a matter of writing values to the array, and write it back into the file. For the actual merging it doesn't matter where the data came from. – GolezTrol Apr 13 '16 at 08:25

0 Answers0