Reply to Re: Is this even possible?

Your name:

Reply:


Posted by Oli Filth on 11/29/05 15:42

rich wrote:
> I have a simply array containing direcotry names like this
>
> $myarray = array("folder1","folder2", "folder3", "folder4");
>
> below I have a foreach action
>
> foreach ($myarray as $value) {
> include($value . "/index.php");
> }
>
> now, inside every 'index.php' is the following
>
> $color = "red";
> $size = "small";
> include("../template.html");

<...SNIP...>

> Ideally I want this to open in a new window but I'm not sure if it's even
> possible to do such a thing with the format that I have already? I can't go
> and edit the index.phps in each directory cause there are over 1000.

If every folder/index.php is exactly the same, except the {$color,
$size} definitions, this is a massive waste of disk space, and an arse
to maintain, as you've just found.

Why not define the $colors and $sizes in a database or a flat-file,
then use the base PHP script to perform the templating?

e.g. with MySQL:

$result = mysql_query("SELECT folderID, color, size FROM table");

while ($row = mysql_fetch_assoc($result))
{
// do template processing here,
// using $row["folderID"], $row["color"], and $row["size"]
}


A similar effect could be achieved with a CSV file.

That way, you can do different template processing depending on
whatever settings you desire, and it's all done from one script.

--
Oli

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация