---
title: "smart index sida"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/43859-smart-index-sida"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "@ndreas"
published: "2002-05-15T22:45:36.000Z"
updated: "2002-05-16T01:42:26.000Z"
replies: 1
views: 177
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/43859-smart-index-sida"
---

# smart index sida

## #1 — @ndreas, 2002-05-15T22:45Z

Tjena,
Jag vill på min index sida kunna inkludera sidor.
Nu funkar scriptet att man kan script .tex. index.php?s=1050
och om sidan inte finns kommer det ett error.
Nu till det lilla problemet, jag vill att om man kommer till index sidan ska det .tex. stå tjenare, men är det en query så ska den inkludera sidan, och finns inte sidan ska det komma ett error.
Skulle vilja ha hjälp att ändra det.
Tack på förhand,
@ndreas

```php
<?
if(file_exists("sida/$s.inc"))
include "sida/$s.inc";
elseif(file_exists("nyhet/$n.inc"))
include "nyhet/$n.inc";
elseif(file_exists("artikel/$a.inc"))
include "artikel/$a.inc";
elseif(file_exists("ad/$ad.inc"))
include "ad/$ad.inc";
elseif(file_exists("recension/$r.inc"))
include "recension/$n.inc";
elseif(file_exists("intervju/$i.inc"))
include "intervju/$i.inc";
elseif(file_exists("link/$l.inc"))
include "link/$l.inc";
else
echo "Ett fel inträffade.";
?>
```

Permalänk: https://www.webforum.nu/p/43859

## #2 — Fuel, 2002-05-16T01:42Z

Snabbhack.... a = avdelning, s = sida. Ex. index.php?a=artikel&s=1050

```php
<?

if(!$a && !$s){ echo "Tjenare!"; } else {

$f = "$a/$s.inc";

if (file_exists($f)) { include($f); } else { echo "ERROR!"; }}

?>
```

Har jag missat nåt får jag skylla på att det är mitt i natten :-)

Permalänk: https://www.webforum.nu/p/674015

---

Tråden på webben: https://www.webforum.nu/amne/php/43859-smart-index-sida
