weightwatcher
Erfahrenes Mitglied
Hi, Leute! hab ein Problem mit meiner Blatterfunction. Und zwr tut sies nit. (Geht nit)!
Habe folgendes Script aber irgendwo steckt halt der Fehlerteufel....
Hier mal die Function mit der ich den Content aus der Datenbank auslese ....
Ich habe die obere Blätterclasse mal in die untere Function eingebaut aber es hat halt nicht funktioniert. Es kamen zwar keine Mysql oder PHP Fehler, doch das script hat nicht seinen Dienst getan...
Hoffe mir kann einer Helfen. MfG und Danke im Voraus Dennis Gack aka weightwatcher!
Habe folgendes Script aber irgendwo steckt halt der Fehlerteufel....
PHP:
<?php
if(!isset($_GET['c'])){$c=0;}else{$c=$_GET['c'];}
echo substr($ctitle,$c,300).'.';
?>
und mit
echo '<a href="weiter.php?c='.($c+300).'">Link</a>';
Gehe ich dann auf die nächste Seite
Hier mal die Function mit der ich den Content aus der Datenbank auslese ....
PHP:
class pages
{
//Construct
function pages ( $db, $title )
{
$this->db = $db;
$this->title = $title;
}
//Get page contents
function get ( $ctitle = '' )
{
//Check if custom page
if ( strlen ( $ctitle ) > 0 )
{
$sql = "SELECT * FROM db_pages WHERE title = '". $ctitle ."'";
$query = $this->db->query ( $sql ) ;
}
else
{
//Check if the page is set
if ( strlen ( $this->title ) == 0 )
{
//Default to the homepage
$sql = "SELECT * FROM db_pages WHERE id = 1";
$query = $this->db->query ( $sql ) ;
}
else
{
//Check database for matching page
$sql = "SELECT * FROM db_pages WHERE title = '". $this->title ."'";
$query = $this->db->query ( $sql ) ;
//Is there no pages matching?
if ( $this->db->rows ( $query ) == 0 )
{
//Default to the homepage
$sql = "SELECT * FROM db_pages WHERE id = 1";
$query = $this->db->query ( $sql ) ;
}
}
}
$page = $this->db->fetch_object ( $query ) ;
//Lets update the views
$newCount = (( $page->views + 1 )) ;
$sql = "UPDATE db_pages SET views = $newCount WHERE id = '". $page->id ."'";
$this->db->query ( $sql ) ;
//Return the output
return $page;
}
//Update pages function
function update ( $id, $title, $content )
{
$sql = "UPDATE db_pages SET title = '". $title ."', content = '". $content ."'";
$sql .= " WHERE id = '". $id ."'";
$this->db->query ( $sql ) ;
return 1;
}
//Add pages function
function add ( $title, $content )
{
$sql = "INSERT INTO db_pages (title, content) VALUES ('". $title ."', '". $content ."')";
$this->db->query ( $sql ) ;
return 1;
}
//Delete pages function
function delete ( $title )
{
$sql = "DELETE FROM db_pages WHERE title = '". $title ."'";
$this->db->query ( $sql ) ;
return 1;
}
//Get all pages
function getall ()
{
$i = 0;
$pages = array(array());
$sql = "SELECT * FROM db_pages ORDER BY title";
$query = $this->db->query ( $sql ) ;
while ( $page = $this->db->fetch_object ( $query ) )
{
$i++;
$pages[$i]['id'] = $page->id;
$pages[$i]['title'] = $page->title;
$pages[$i]['content'] = $page->content;
$pages[$i]['last_update'] = $page->last_update;
$pages[$i]['views'] = $page->views;
}
return $pages;
}
}
?>
Ich habe die obere Blätterclasse mal in die untere Function eingebaut aber es hat halt nicht funktioniert. Es kamen zwar keine Mysql oder PHP Fehler, doch das script hat nicht seinen Dienst getan...
Hoffe mir kann einer Helfen. MfG und Danke im Voraus Dennis Gack aka weightwatcher!