[PHP] Functions

Gestart doorWouter0 reacties28 weergaven

1 berichten · pagina 1 van 1

Wouter

Lid · Topicstarter

Berichten
3.540
Reputatie
0
Punten
0,01
Lid sinds
Laatst gezien
Beste 02xers

voor de layout van mijn nieuwe site (waar mensen hun site kunnen maken) maak ik gebruik van functies ( zodat het mogelijk is om een andere layout te hebben), het probleem is nu dat het menu ook uit de database gehaald moet worden, en ik hem er met geen enkele functie terug krijg.

Menu wordt opgehaald uit database
(select * from pagina where site=site) en heeft meerdere paginas dus ...

site.php ( waar sites met $_GET[site] worden opgehaald)

[COLOR= #0000BB]<?[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"instellingen.php"[/COLOR][COLOR= #007700]);

}[/COLOR]
[COLOR= #0000BB]$site[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]site[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"select * from site WHERE eigenaar = $site"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$object[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])){[/COLOR]
[COLOR= #0000BB]$site_titel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]titel[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$site_layout[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]layout[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$site_eigenaar[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]eigenaar[COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pagina[/COLOR][COLOR= #007700]])){[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"select * from pagina WHERE site = $site AND hoofdpagina = 1"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$object[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])){[/COLOR]
[COLOR= #0000BB]$get_pagina[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]id[COLOR= #007700];
}
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$get_pagina[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]pagina[/COLOR][COLOR= #007700]];
}[/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"select * from pagina WHERE id = $get_pagina"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$object[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700])){[/COLOR]
[COLOR= #0000BB]$pagina_id[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]id[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$pagina_titel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]titel[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$pagina_tekst[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]tekst[COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$pagina_site[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$object[/COLOR][COLOR= #007700]->[/COLOR]site[COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"layouts/$site_layout/template.php"[/COLOR][COLOR= #007700]);[/COLOR]


design_boven[COLOR= #007700]([/COLOR][COLOR= #DD0000]"$pagina_titel"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"$site_titel"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"$site"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"$siteurl"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"$get_pagina"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pagina_site[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]$site_eigenaar[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Deze pagina behoort niet tot deze website"[/COLOR][COLOR= #007700]);
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$pagina_tekst"[/COLOR][COLOR= #007700]); 

}[/COLOR]
design_onder[COLOR= #007700]([/COLOR][COLOR= #DD0000]"1"[/COLOR][COLOR= #007700]);[/COLOR]
?>


Dit is template.php

[COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]function[/COLOR] design_boven[COLOR= #007700]([/COLOR][COLOR= #0000BB]$titel[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$site_titel[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$site[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$siteurl[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$get_pagina[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"instellingen.php"[/COLOR][COLOR= #007700]);[/COLOR] 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$site_titel[/COLOR][COLOR= #007700];[/COLOR] ?> - [COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$titel[/COLOR][COLOR= #007700];[/COLOR] ?></title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000][/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$siteurl[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR] ?>layouts/1/style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="logo">
    <h1><a href="#">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$site_titel[/COLOR][COLOR= #007700];[/COLOR] ?></a></h1>
    <p><em></em></p>
</div>
<hr />
<!-- end #logo -->
<div id="page">
    <div id="page-bgtop">
        <div id="page-bgbtm">
            <div id="content">
                <div class="post">
                    <div class="post-bgtop">
                        <div class="post-bgbtm">
                            <h2 class="title"><a href="#">[COLOR= #0000BB]<?[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$titel[/COLOR] ?></a></h2>
                            <div class="entry">
                            [COLOR= #0000BB]<?[/COLOR]
                            [COLOR= #007700]}
                            function[/COLOR] design_onder[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ads[/COLOR][COLOR= #007700]){[/COLOR]
                            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ads[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #DD0000]1[/COLOR][COLOR= #007700]){[/COLOR]
                            ?>
                            [COLOR= #0000BB]<?[/COLOR]
                            [COLOR= #007700]}[/COLOR]
                            ?>
         </div>
                        </div>
                    </div>
                </div>
                
            </div>
            <!-- end #content -->
            <div id="sidebar">
                <ul>
                    <li>
                        <h2>Menu</h2>
                            <ul>
HIER MOET HET MENU NU TUSSEN!
                            <ul>
                    </li>
                    
                </ul>
            </div>
            <!-- end #sidebar -->
        </div>
    </div>
</div>
<div id="footer">
    <p>&copy; inkkiller.be <a href="http://www.freecsstemplates.org/">Design</a>.</p>
</div>
<!-- end #footer -->
</body>
</html>


[COLOR= #0000BB]<?[/COLOR]
[COLOR= #007700]}[/COLOR]
?>


Voila, ik hoop dat jullie me kunnen helpen!
Voorbeeld: w w w . i n k k i l l e r . b e

Wouterr
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren