I am doing a website using php and mysql.
I want to generate .conf files when click button with names of database values.
for example: there is a database table named as "config". In that there is a field "trunkname" that is unique. I want to click .conf files when click submit like extension. trunkname value here.con, etc.
If "config" table have 3 rows. Trunknames are value1,value2,value3.
Then i the script generate 3 files named as extension.value1.conf,extension.value2.conf and extension.value3.conf files with individual data.
I have generated files with my script. But total table data was inserted into each file. but i want to insert individual data into individual file. here is my script.
<?
$ext_content[] = "; do not edit this file, this is an auto-generated file";
$ext_content[] = "; all modifications must be done from the web GUI";
$ext_content[] = "";
$ext_content[] = "";
$sql_trunkname=mysql_query("select * from sip");
while($row_trunkname=mysql_fetch_array($sql_trunkname)) {
$trunk_name[]=$row_trunkname['trunk'];
}
foreach($trunk_name as $v) {
$file_sipext="extensions.$v.conf";
$path_sipext=$dh.$file_sipext;
`sudo chmod 777 $path_sipext`;
$create_sipext=fopen($path_sipext,"w+");
$ext_content[] = $v;;
$data_ext = implode("\n", $ext_content);
file_put_contents($path_sipext, $data_ext);
fclose($create_sipext);
if($create_sipext) {
echo "files generated";
} else {
echo "files not generated";
}
}
?>
help me out. Its utgent. Client waiting there.