XHTMLforum

XHTMLforum (http://xhtmlforum.de/index.php)
-   Serveradministration und serverseitige Scripte (http://xhtmlforum.de/forumdisplay.php?f=80)
-   -   Brauche Hilfe mit Includes (http://xhtmlforum.de/showthread.php?t=40592)

ConiKost 03.07.2006 19:11

Brauche Hilfe mit Includes
 
Hallo!
Ich habe meine Seite nun dymamisch in PHP umgewandelt.

Jetzt wollte ich den Punkt "Inhalt" Dynamisch laden lassen. Also z.B über Inhalt.inc.php?Inhalt=FOO

Ok, dafür habe ich mir eine Inhalt.inc.php gemacht mit:

Das ganze klappt auch super. Aber ein Punkt fehlt mir. Wenn ich nun die Index.php aufrufe, wie löse ich das hier, dass entsprechend die Seite aufgerufen wird die ich will.

Inhalt.inc.php

Code:

<?php
$Inhalt = $_GET['Inhalt'];
if (empty($Inhalt))
  { include ('./News.inc.php'); }
elseif ($Inhalt = "test")
  { echo 'TEST';}
?>

Index.php

Code:

<?php include ('./Doctype.inc.php'); ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
  <head>
    <?php include ('./Head.inc.php'); ?>
  </head>
  <body>
          <div id="Metabox">
      <div id="Header">
        <?php include ('./Header.inc.php'); ?>
      </div>
      <div id="MenuL">
        <?php include ('./MenuL.inc.php'); ?>
      </div>
      <div id="Inhalt">
        <?php include ('./Inhalt.inc.php'); ?>
      </div>
      <div id="MenuR">
        <?php include ('./MenuR.inc.php'); ?>
      </div>
      <div id="Footer">
        <?php include ('./Footer.inc.php'); ?>
      </div>
    </div>               
  </body>
</html>


derHund 03.07.2006 19:15

Wo liegt das Problem? Deine Frage ist unverständlich.

Legt Dir ein Array an, welches als Schlüssel den übergebenen Wert, als Wert den zu includierenden Filenamen trägt. Wenn die übergebene Variable existiert und nicht leer ist, includierst Du entsprechende Seite, falls sie existiert - sonst die Hauptseite oder eine 404.

Boris 04.07.2006 01:33

$Inhalt = "test" ist falsch ... der Vergleichoperator wäre ==, sprich:

if($Inhalt == "test") ;)

Yhi 04.07.2006 12:05

... und switch/case wär in diesem Fall besser :)


Alle Zeitangaben in WEZ +2. Es ist jetzt 09:07 Uhr.

Powered by vBulletin® Version 3.8.11 (Deutsch)
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

© Dirk H. 2003 - 2023