I have a fully functional PHP file to run the following html code(it generates all the images that are stored in a SQL database, they are linked to layers…this isn’t the part of the code I need help with).
[code]
{item.NAME}
But I want to be able to put the layers into categories, so that instead of displaying all images from those layers at once(or only one layer at a time), I can display a few at a time.
To do this, I wrote a second php script to create a new php file for each layer and replace the contents of the previous code so that the new script will be specific to the layer selected…
[php]<?php
$filename = “{item.LAYER} . ‘.php’”;
$file = = “/tabscript.php”;
$fs = fopen("$file",“w+”) or exit(“Unable to open file!”);
$contents .= fgets($fs, 1024);
$string= $contents
$patterns[0]=“LAYER”
$replacements[0]="{item.LAYER}x++"
echo preg_replace($patterns, $replacements, $string);
fclose($file);
file_put_contents($filename, $content);
?>[/php]
1st problem. The code isn’t doing what it should, I know I must have messed it up somewhere but I don’t know where.
2nd problem. I don’t know how to save the replaced contents of the first file as the new contents of the new file.
Maybe I’m going about this entirely wrong, but I am useless at writing SQL db queries. Any help would be appreciated.