Glossar Script

Meinst du das so ?
PHP:
if(isset($_GET['list']) && !empty($_GET['list'])
{
    //  Eintraege anzeigen
}
else
{
    // Index anzeigen
}
 
Hallo,

so jetzt läuft es, vielen Dank für eure Mithilfe. Die Gemeinschaft hat geholfen, also wird es hier komplett veröffentlicht.

Das Script:

PHP:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require ("inc/db/db.html");

/* Built the menu */
// Set ABC in Array for the menu
$abc = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");


// Give out the menu
echo "<ul class=\"lexikon_menu\">\n";
foreach($abc as $menu)
{
    echo "<li><a href=\"tabs.html?list=".$menu."\">".strtoupper($menu)."</a></li>\n";
}
echo "</ul>\n";
/* Menu is build */


/* The Script load Character Data when $_GET is active, when not the script will load the Index. */
$list = (isset($_GET['list'])) ? $_GET['list'] : '';
if(!empty($list) && $list != '') {
    // Database Statement and handle the connection
    $query = $db->query("SELECT id, erster, title, beschreibung FROM `glossar` WHERE erster='".addslashes($list)."'");
    if (!$query)
    {
        die("Execute query error, because: " . $db->errorInfo());
    }
    $query->execute();

    // Give out the Database Entrys
    while($row = $query->fetch(PDO :: FETCH_ASSOC))
    {
        echo "<ul>\n";
        echo "<li>".htmlspecialchars($row['title'])."</li>\n";
        echo "<li>".htmlspecialchars($row['beschreibung'])."</li>\n";
        echo "</ul>\n";
    }
}else {

    // Build the statement for Database with PDO
    $query = $db->prepare("SELECT id, erster, title, beschreibung FROM `glossar` ORDER BY erster");
    if (!$query)
    {
        die("Execute query error, because: " . $db->errorInfo());
    }
    $query->execute();

    // Give out the Index of Table
    while ($row = $query->fetch(PDO :: FETCH_ASSOC)) {
        echo "<ul>\n";
        echo "<li>".htmlspecialchars($row['title'])."</li>\n";
        echo "<li>".htmlspecialchars($row['beschreibung'])."</li>\n";
        echo "</ul>\n";
    }
}
/* Index is loaded */

/* At end we close active connections */
$row = null;
$query = null;
$db = null;
?>

Die MYSQL Datenbank:

Code:
CREATE TABLE IF NOT EXISTS `glossar` (
  `id` int(100) NOT NULL AUTO_INCREMENT,
  `erster` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `beschreibung` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8

Die ID erklärt sich von selber, erster ist für den Anfangsbuchstaben, title und Beschreibung erklären sich auch von selber.

Vielen Dank, für die Hilfe.

MFG
Silvio
 
Zurück