PHP-Code:
//GET PageID
if(isset($_GET['pageID'])){
show_page($_GET['pageID']);
}
else{
}
Nun zu meiner zweiten frage, kann mir da jemand vll. tipps geben.
//GET PageID
if(isset($_GET['pageID'])){
show_page($_GET['pageID']);
}
else{
}
#FUNCTION show_page // Hole die Pages aus der Datenbank
function show_page($param) {
global $db, $smarty;
$param = mysql_real_escape_string($param); //(sql-I)
$result = $db->query("
SELECT
pageTitle as title, pageContent as content
FROM
d3b_pages
WHERE
pageID = '$param'
LIMIT 1
");
$row = $db->fetch_array($result);
$db->free_result($result);
//ganze smarty-assignment-zeugs
$smarty->assign('content', $row['content']);
$smarty->assign('title', $row['title']);
//GET PageID
if(isset($_GET['pageID'])){
show_page($_GET['pageID']);
}
else{
}
//Output index.tpl
$smarty->display('index.tpl');
}//Ende Function
$pageID = isset($_GET['pageID']) ? intval($_GET['pageID']) : 1; //Seite 1 wird immer angezeigt
show_page($pageID);
{include file="pages.tpl"}
{include file="main.tpl"}
function show_page($param) {
global $db, $smarty;
$id = $_GET['pageID'];
$_GET['id'] = $_GET['pageID'];
//$name = $_GET['pageName'];
$result = $db->query("
SELECT
pageID as id, pageNAME as pname, pageTitle as ptitle, pageContent as pcontent
FROM
d3b_pages
WHERE
pageID = '$id'
");
while($row = $db->fetch_array($result)) {
$smarty->assign('content', $row['pcontent']);
}
}
function show_page($param) {
global $db, $smarty;
$param=mysql_real_escape_string($param); //(sql-I)
$result = $db->query("
SELECT
pageContent
FROM
d3b_pages
WHERE
pageID = '$param'
LIMIT 1
");
$row = $db->fetch_array($result))
$smarty->assign('content', $row['pageContent']);
mysql_free_result($result);
}
EDIT:
noch schutz gegen sql-I ergänzt, um nicht nach DDSIG schuld zu sein.
function show_page($id = 1) {
}
function show_page($id){
global $db,$smarty;
$result = $db->query( "SELECT * FROM ` bla` WHERE `pageID` = {$id}" );
if(!$result){
//tu was
}
//hier kommt das ganze smarty-assignment-zeugs
//die rekursion die hier steht nimmst du raus
//if(isset($_GET['pageID'])){ show_page($_GET['pageID']); }else{}
//und noch anzeigen
$smarty->display('index.tpl');
}
require_once 'page_shower.php';
$id = isset($_GET['pageID']) ? intval($_GET['pageID']) : 1; //oder was auch immer default ist
//$smarty erzeugen
//$db erzeugen
show_page($id);
function show_page($id = 1) {
}
function show_page($param) {
global $db, $smarty;
$id = $_GET['pageID'];
$_GET['id'] = $_GET['pageID'];
$result = $db->query("
SELECT
pageID as id, pageNAME as pname, pageTitle as ptitle, pageContent as pcontent
FROM
d3b_pages
WHERE
pageID = '$id'
");
if (isset($_GET['pageID'])) {
show_page($_GET['pageID']);
} else {
show_page('1');
}
function show_page($param) {
global $db, $smarty;
$id = $_GET['pageID'];
$_GET['id'] = $_GET['pageID'];
//$name = $_GET['pageName'];
$result = $db->query("
SELECT
pageID as id, pageNAME as pname, pageTitle as ptitle, pageContent as pcontent
FROM
d3b_pages
WHERE
pageID = '$id'
");
while($row = $db->fetch_array($result)) {
$smarty->assign('content', $row['pcontent']);
}
}
if (isset($_GET['pageID'])) {
show_page($_GET['pageID']);
} else {
echo "ERRRRRRRRRRRRROOOOOOOOOOOOR";
}
$smarty->display("index.tpl");
<div id="container"> {include file="header.tpl"} <div id="main"> {include file="menu.tpl"} <div id="content"> {include file="main.tpl"} </div> </div> {include file="footer.tpl"} </div>
+ while()-schleife bei einem Datensatz überflüssig
showPage($_GET['pageID']);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <link rel="stylesheet" type="text/css" href="./design/images/main.css" /> </head> <body> <div id="container"> {include file="header.tpl"} <div id="main"> {include file="menu.tpl"} <div id="content"> {include file="main.tpl"} </div> </div> {include file="footer.tpl"} </div> </body> </html>
function showPage($pageID) {
global $db;
$id = $_GET['pageID'];
$result = $db->query("
SELECT
pageNAME as pname, pageTitle as ptitle, pageContent as pcontent
FROM
d3b_pages
WHERE
pageID = '$id'
");
while($row = $db->fetch_array($result)) {
echo "<title>".$row['pname']."</title>";
echo $row['pcontent'];
}
}
showPage($_GET['pageID']);
Einen Kommentar schreiben: