Kóði: Velja allt
<?php
$Topic_Array = array();
$Forum = array("");
// Create DOM from URL or file
$html = file_get_html('http://spjall.vaktin.is/');
// find all Forums and cat them
foreach($html->find('a[class=forumtitle]') as $element)
{
$TempHref = str_replace("./", "http://spjall.vaktin.is/",$element->href);
$TempHTML = file_get_html($TempHref);
$TempClass = new Forum($TempHref,$element->plaintext,$TempHTML);
array_push($Forum,$TempClass);
}
array_push($Forum,$TempClass);
class Topic
{
public $Href;
public $Title;
public $Posts;
public $Views;
public $LastPost;
public $Owner;
function __Construct($Href,$Title,$Posts,$Views,$LastPost,$Owner)
{
$this->Href = $Href;
$this->Title = $Title;
$this->Posts = $Posts;
$this->Views = $Views;
$this->LastPost = $LastPost;
$this->Owner = $Owner;
}
function Read()
{
}
function Answer()
{
}
function Flag()
{
}
}
class Forum
{
public $Href;
public $Title;
public $Topic;
public $TempHref;
public $TempTitle;
public $TempPosts;
public $TempViews;
public $TempLastPost;
public $Owner;
public $TempTopic;
function __Construct($Href,$Title,$HTML)
{
$this->Href = $Href;
$this->Title = $Title;
$this->Topic = $HTML;
}
function Read()
{
global $Topic_Array;
echo $this->Href;
foreach($this->Topic->find('ul[class=topiclist topics] li') as $element)
{
$this->TempHref = $element->find('dl dt a[class=topictitle]',0)->href;
$this->TempHref = str_replace("./", "http://spjall.vaktin.is/",$this->TempHref);
$this->TempTitle = $element->find('dl dt a',0)->plaintext;
$this->TempPosts = $element->find('dd[class=posts]',0)->innertext;
$this->TempViews = $element->find('dd[class=views]',0)->innertext;
$this->TempLastPost = $element->find('dd[class=lastpost] span a',0)->innertext;
$this->Owner = $this->Href;
$this->TempTopic = new Topic($this->TempHref,$this->TempTitle,$this->TempPosts,$this->TempViews,$this->TempLastPost,$this->Owner);
array_push($Topic_Array,$this->TempTopic);
}
}
function NewTopic()
{
}
}
Ég er bæði latur og hálfviti þegar kemur að mysql þannig að nennir einhver að skella á mig SQL commandinu til að búa til þessi 2 table:
Kóði: Velja allt
Forum:
varchar - Href;
varchar -Title;
Topic:
varchar - Href;
varchar - public Title;
int - public Posts;
int - Views;
varchar LastPost;
int - Owner;
Með fyrirfram þökk athenaV8