uitklapmenu
Auteur: venkatesaya - 13 april 2009 - 12:24 - Gekeurd door: Joel - Hits: 3316 - Aantal punten: 0.67 (3 stemmen)
1. aanmaken db boeken
2. aanmaken tabel boek in db boeken
CREATE TABLE `boek` (
`boek_id` bigint(20) NOT NULL auto_increment,
`titel` varchar(255) default NULL,
`boek` varchar(50) default NULL,
`hoofdstuk` varchar(5) default NULL,
`paragraaf` varchar(5) default NULL,
`txt` text,
`sort_h_p` varchar(9) default NULL,
PRIMARY KEY (`boek_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1111;
CREATE TABLE `boek` ( `boek_id` bigint(20) NOT NULL AUTO_INCREMENT, `titel` varchar(255) DEFAULT NULL, `boek` varchar(50) DEFAULT NULL, `hoofdstuk` varchar(5) DEFAULT NULL, `paragraaf` varchar(5) DEFAULT NULL, `txt` text, `sort_h_p` varchar(9) DEFAULT NULL, PRIMARY KEY (`boek_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1111;
3. records aanmaken in tabel boek
INSERT INTO `boek` (`boek_id`, `titel`, `boek`, `hoofdstuk`, `paragraaf`, `txt`, `sort_h_p`) VALUES
(6, 'In adipiscing.', 'Lorem Ipsum', '2', '3', 'In adipiscing, augue et consectetur vestibulum, dolor mauris iaculis risus, non tristique nisi mauris sit amet nunc. Curabitur convallis lorem quis magna.', '02_03'),
(9, 'Vivamus hendrerit erat at massa.', 'Lorem Ipsum', '3', '3', 'Vivamus hendrerit erat at massa. Quisque non nisi. Aenean eu arcu in sapien pretium porta. Nam lacinia rhoncus lacus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. ', '03_03'),
(3, 'Nunc vitae urna.', 'Lorem Ipsum', '1', '3', 'Nunc vitae urna. Sed egestas. Fusce mauris mauris, pharetra at, auctor et, elementum nec, dui. Suspendisse vestibulum urna sit amet odio. ', '01_03'),
(5, 'Suspendisse potenti.', 'Lorem Ipsum', '2', '2', 'Suspendisse potenti. Ut semper placerat purus. Praesent sed justo quis diam dictum eleifend. Suspendisse elit. Nam et tortor. Donec iaculis. Praesent sagittis risus eget eros. ', '02_02'),
(2, 'In suscipit fringilla massa.', 'Lorem Ipsum', '1', '2', 'In suscipit fringilla massa. Donec sit amet ligula. Fusce lorem lorem, ultricies sed, iaculis in, laoreet sit amet, justo. Quisque placerat gravida orci. ', '01_02'),
(1, 'Lorem ipsum dolor.', 'Lorem Ipsum', '1', '1', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet lectus sit amet orci egestas accumsan. Quisque fermentum lorem id arcu. ', '01_01'),
(4, 'Vestibulum ante ipsum.', 'Lorem Ipsum', '2', '1', 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam pulvinar. Quisque sed arcu et mi pharetra porta. Etiam nec mauris. ', '02_01'),
(7, 'Cras et nibh vel dui luctus malesuada.', 'Lorem Ipsum', '3', '1', 'Cras et nibh vel dui luctus malesuada. Duis dapibus rutrum ante. Aliquam justo. Proin blandit dapibus arcu. Nulla libero arcu, ornare sit amet, pharetra non, bibendum at, elit. ', '03_01'),
(8, 'In ac libero eu lacus tincidunt luctus.', 'Lorem Ipsum', '3', '2', 'In ac libero eu lacus tincidunt luctus. Nulla mattis tincidunt turpis. Nam urna nunc, interdum non, ornare quis, vestibulum vel, dolor. ', '03_02');
INSERT INTO `boek` (`boek_id`, `titel`, `boek`, `hoofdstuk`, `paragraaf`, `txt`, `sort_h_p`) VALUES (6, 'In adipiscing.', 'Lorem Ipsum', '2', '3', 'In adipiscing, augue et consectetur vestibulum, dolor mauris iaculis risus, non tristique nisi mauris sit amet nunc. Curabitur convallis lorem quis magna.', '02_03'), (9, 'Vivamus hendrerit erat at massa.', 'Lorem Ipsum', '3', '3', 'Vivamus hendrerit erat at massa. Quisque non nisi. Aenean eu arcu in sapien pretium porta. Nam lacinia rhoncus lacus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. ', '03_03'), (3, 'Nunc vitae urna.', 'Lorem Ipsum', '1', '3', 'Nunc vitae urna. Sed egestas. Fusce mauris mauris, pharetra at, auctor et, elementum nec, dui. Suspendisse vestibulum urna sit amet odio. ', '01_03'), (5, 'Suspendisse potenti.', 'Lorem Ipsum', '2', '2', 'Suspendisse potenti. Ut semper placerat purus. Praesent sed justo quis diam dictum eleifend. Suspendisse elit. Nam et tortor. Donec iaculis. Praesent sagittis risus eget eros. ', '02_02'), (2, 'In suscipit fringilla massa.', 'Lorem Ipsum', '1', '2', 'In suscipit fringilla massa. Donec sit amet ligula. Fusce lorem lorem, ultricies sed, iaculis in, laoreet sit amet, justo. Quisque placerat gravida orci. ', '01_02'), (1, 'Lorem ipsum dolor.', 'Lorem Ipsum', '1', '1', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet lectus sit amet orci egestas accumsan. Quisque fermentum lorem id arcu. ', '01_01'), (4, 'Vestibulum ante ipsum.', 'Lorem Ipsum', '2', '1', 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam pulvinar. Quisque sed arcu et mi pharetra porta. Etiam nec mauris. ', '02_01'), (7, 'Cras et nibh vel dui luctus malesuada.', 'Lorem Ipsum', '3', '1', 'Cras et nibh vel dui luctus malesuada. Duis dapibus rutrum ante. Aliquam justo. Proin blandit dapibus arcu. Nulla libero arcu, ornare sit amet, pharetra non, bibendum at, elit. ', '03_01'), (8, 'In ac libero eu lacus tincidunt luctus.', 'Lorem Ipsum', '3', '2', 'In ac libero eu lacus tincidunt luctus. Nulla mattis tincidunt turpis. Nam urna nunc, interdum non, ornare quis, vestibulum vel, dolor. ', '03_02');
4. aanmaken file index.php
5. aanmaken file stijl.css
hoofdstuk en paragraaf zijn NRS in de db
je krijgt een nette url: index.php?hoofdstuk=1¶graaf=1
veld sort_h_p kan dienen om de records te sorteren
|
Code: |
index.php
<html><head><title>menu</title><link href="stijl.css" rel="stylesheet" type="text/css"></head><body>
<?php
if ( isset( $_GET["hoofdstuk"] ) ) {
$hoofdstuk = $_GET["hoofdstuk"] ;
} else {
$hoofdstuk = "";
}
?>
<div class="wrap">
<h3>Lorem Ipsum</h3>
<div class="menu">
<?php
$hoofdstuk_txt[1] = array( "hoofdstuk 1" );
$hoofdstuk_txt[2] = array( "hoofdstuk 2" );
$hoofdstuk_txt[3] = array( "hoofdstuk 3" );
$nav = array(
"1" => array( "Lorem ipsum dolor.", "In suscipit fringilla massa.", "Nunc vitae urna." ),
"2" => array( "Vestibulum ante ipsum.", "Suspendisse potenti.", "In adipiscing." ),
"3" => array( "Cras et nibh vel dui luctus malesuada.", "In ac libero eu lacus tincidunt luctus.", "Vivamus hendrerit erat at massa." )
);
foreach( $nav as $key => $value ) {
echo " <h4> <a href='" . $_SERVER['PHP_SELF'] . "?hoofdstuk=" . $key . "'> " . $hoofdstuk_txt[$key][0] . " </a> </h4> " . "\n";
if ( $hoofdstuk == $key ) {
foreach( $value as $key2 => $value2 ) {
$paragraaf_txt = $key2 + 1;
echo "<ul>" ;
echo "<li>" ;
echo " <a href='" . $_SERVER['PHP_SELF'] . "?hoofdstuk=" . $key . "&paragraaf=" . $paragraaf_txt . "'>" . $value2 . "</a>" . "\n";
echo "</li>" ;
echo "</ul>" ;
}
}
}
?>
</div>
<div class="content">
<?php
$connect_server = mysql_connect( 'host', 'user', 'pasw' ) ;
if ( !$connect_server ) {
die( 'probleem met connectie ' . mysql_error() . ' (foutcode= ' . mysql_errno() . ')' ) ;
} else {
echo 'connectie gelukt ' ;
}
$connect_db = mysql_select_db( 'database' ) ;
if ( !$connect_db ) {
die( 'db bestaat niet ' ) ;
} else {
echo 'db bestaat ' ;
}
if ( $hoofdstuk == "" ) {
echo " ";
} elseif ( !isset( $_GET["paragraaf"] ) ) {
echo " ";
} else {
$paragraaf = $_GET["paragraaf"];
$query = "SELECT * FROM boek WHERE hoofdstuk='" . $hoofdstuk . "' AND paragraaf='" . $paragraaf . "' ";
$result = mysql_query( $query ) or die( mysql_error() );
while ( $row = mysql_fetch_array( $result ) ) {
echo "<div class='titel'>" ;
echo $row['titel'] ;
echo "</div>";
echo "<div class='txt'>" ;
echo nl2br( $row['txt'] ) ;
echo "</div>";
}
}
?>
</div>
</div>
</body></html>
<html><head><title>menu</title><link href="stijl.css" rel="stylesheet" type="text/css"></head><body> <?php if ( isset( $_GET["hoofdstuk"] ) ) { $hoofdstuk = $_GET["hoofdstuk"] ; } else { $hoofdstuk = ""; } ?> <div class="wrap"> <h3>Lorem Ipsum</h3> <div class="menu"> <?php $hoofdstuk_txt[1] = array( "hoofdstuk 1" ); $hoofdstuk_txt[2] = array( "hoofdstuk 2" ); $hoofdstuk_txt[3] = array( "hoofdstuk 3" ); "1" => array( "Lorem ipsum dolor.", "In suscipit fringilla massa.", "Nunc vitae urna." ), "2" => array( "Vestibulum ante ipsum.", "Suspendisse potenti.", "In adipiscing." ), "3" => array( "Cras et nibh vel dui luctus malesuada.", "In ac libero eu lacus tincidunt luctus.", "Vivamus hendrerit erat at massa." ) ); foreach( $nav as $key => $value ) { echo " <h4> <a href='" . $_SERVER['PHP_SELF'] . "?hoofdstuk=" . $key . "'> " . $hoofdstuk_txt[$key][0] . " </a> </h4> " . "\n"; if ( $hoofdstuk == $key ) { foreach( $value as $key2 => $value2 ) { $paragraaf_txt = $key2 + 1; echo " <a href='" . $_SERVER['PHP_SELF'] . "?hoofdstuk=" . $key . "&paragraaf=" . $paragraaf_txt . "'>" . $value2 . "</a>" . "\n"; } } } ?> </div> <div class="content"> <?php if ( !$connect_server ) { } else { echo 'connectie gelukt ' ; } if ( !$connect_db ) { die( 'db bestaat niet ' ) ; } else { } if ( $hoofdstuk == "" ) { } elseif ( !isset( $_GET["paragraaf"] ) ) { } else { $paragraaf = $_GET["paragraaf"]; $query = "SELECT * FROM boek WHERE hoofdstuk='" . $hoofdstuk . "' AND paragraaf='" . $paragraaf . "' "; echo "<div class='titel'>" ; echo "<div class='txt'>" ; } } ?> </div> </div> </body></html>
stijl.css
body {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;}
h3 {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;margin:23px;color:#990000;padding-left:23px;}
h4 {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;margin:3px;border-bottom:#CCCCCC 1px solid;}
ul {list-style:none;margin:0;}
a {text-decoration:none;color:#000066;}
a:hover {text-decoration:none;color:#FF0000;}
.wrap {width:800px;}
.menu {border:#000000 1px solid;margin:3px;padding-bottom:23px;float:left;width:300px;}
.content {border:#000000 1px solid;margin:3px;padding-bottom:23px;float:right;width:480px;}
.titel {border-bottom:#CC0000 1px solid;margin:9px;color:#CC0000;padding-left:23px;}
.txt {margin:3px;}
body {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;} h3 {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;margin:23px;color:#990000;padding-left:23px;} h4 {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;margin:3px;border-bottom:#CCCCCC 1px solid;} ul {list-style:none;margin:0;} a {text-decoration:none;color:#000066;} a:hover {text-decoration:none;color:#FF0000;} .wrap {width:800px;} .menu {border:#000000 1px solid;margin:3px;padding-bottom:23px;float:left;width:300px;} .content {border:#000000 1px solid;margin:3px;padding-bottom:23px;float:right;width:480px;} .titel {border-bottom:#CC0000 1px solid;margin:9px;color:#CC0000;padding-left:23px;} .txt {margin:3px;}
Download code (.txt)
|
|
Stemmen |
Niet ingelogd. |
|