Blog systeem

Gestart doorTeletext16 reacties18 weergaven

17 berichten · pagina 1 van 2

Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey. Op http://diarenek.atwebpages.com/ (one2xs server doet het tijdelijk niet) heb ik een soort blog systeem gemaakt, waar ik via phpMyAdmin kan posten. Dit wil ik later aanpassen zodat ik het op een aparte pagina kan doen maar dat terzijde. Nu heb ik een probleem. Voor elke post moet een apart vakje komen. De titel moet in het zwarte gedeelte komen en de body (het bericht) in dat beige vak er onder. Nu het probleem zoals je ziet, alles word in het beige vak gepropt.
Ik gebruik de functie get_content() om de post uit de database te halen, zo haalt hij dus alles mee. Hoe kan ik zorgen dat hij alleen de body mee haalt? Is dat iets met get_content(body) of zo?

Alvast bedankt smile
0
Berichten
4.451
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Laat je script even zien, hier kan je niks mee smile
0
Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Haha, ik wilde hem hier niet neer zetten omdat iemand hem misschien zou kopiëren, maar nu ik er bij na denk, het is een simpel script dus waarom niet. Geen idee of het allemaal goed is :

index.php

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

[COLOR= #0000BB]$obj[/COLOR] [COLOR= #007700]= new[/COLOR] modernCMS[COLOR= #007700]();[/COLOR]
    [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]host [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]fdb3.awardspace.com[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]username [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]********[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]password [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]******[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]db [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]********[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$obj[/COLOR][COLOR= #007700]->[/COLOR]connect[COLOR= #007700]();[/COLOR]

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Henicos | Blog</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div id="container">

<div id="header"></div>

<div id="contenttop"><div class="contenttoptekst"></div></div>
<div id="content"><div class="contenttekst"><?=$obj->get_content()?><br><br><br><br><br></div></div>

</div

</body>
</html>


cms_class.php (zit in de map _class)

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/class"]class[/URL] modernCMS[COLOR= #007700]{

    var[/COLOR] [COLOR= #0000BB]$host[/COLOR][COLOR= #007700];
    var[/COLOR] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700];
    var[/COLOR] [COLOR= #0000BB]$password[/COLOR][COLOR= #007700];
    var[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700];
    
    function[/COLOR] connect[COLOR= #007700]() {[/COLOR]
    [COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]host[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]username[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]password[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/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]db[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);
    }
    
    function[/COLOR] get_content[COLOR= #007700]() {[/COLOR]
    [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM cms_content ORDER BY id DESC"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/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]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p>[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]body[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]<p>[/COLOR][COLOR= #007700];
    }
}
    function[/COLOR] get_title[COLOR= #007700]() {[/COLOR]
    [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT * FROM cms_content ORDER BY id DESC"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/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]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="contenttoptekst>[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]].[/COLOR] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];
        }
        }
}[/COLOR]
?>
0
Berichten
4.451
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kan je even duidelijk uitleggen wat er nu in het zwarte en wat er in het beige moet komen. Want als ik op je blog kijk, zie ik in het zwarte: Hallo! en in het beige zie ik: "Tweede

Tressdg aregfds

Eerste post!

Dit is een test."

Dus ik weet wat er nu precies moet gebeuren
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Maak 3 functies:

getInfo ()
Deze haalt alle info op en zet het in een private array in de class

getTitle ()
Deze kijkt of de private array gevuld is, zoja: return de title. Zonee: roep getInfo aan en haal vervolgens de title op.

getContent ()
Deze kijkt of de private array gevuld is, zoja: return de content. Zonee: roep getInfo aan en haal vervolgens de content op.
0
Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik snap het nu, maar dit lukt me nog niet:

Voor elke aparte rij in me tabel wil ik een nieuw vakje. Nu word alles in 1 vak zet.
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
While ($fetch = mysql_fetch_array($query))
{
// Echo code
}
0
Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
bij echo code dus :

<div id="contenttop"><div class="contenttoptekst"><?=$obj->get_title()?></div></div>
<div id="content"><div class="contenttekst"><?=$obj->get_content()?><br><br><br><br><br></div></div>


?
0
Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dit moet je niet doen in index.php maar in cms_class.php Je verwerkt in je while een tabel die je dan met $obj->get_content() automatisch ophaalt
0
Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja dat bedoel ik Marjolein, die 2 regels moet je die dan in cms_class.php zetten? (dacht ik bij die post)

Wat zorgt er dan voor dat er een nieuw vak word gemaakt?

edit: heb aangepast wat ik tot nu toe heb.
0
Berichten
15.446
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
die while zorgt dat alles zich herhaald, dus als er 3 berichten in je database staan worden die 3 berichten weergegeven. Dus alles wat je in die while zet wordt dan automatisch ook 3x herhaald
0
Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wauw super uitleg in die 2 zinnen thumbsupZou je alleen nog een voorbeeld kunnen maken hoe de while er dan uit zou moeten zien?
0
Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oke ik ben al een eind verder, nog 1 dingetje wil niet.
Ik heb zeg maar een formulier dat ik in kan vullen, dan word de info naar de database gestuurd en die plaatst het op mijn beginpagina. Dit werkt allemaal, maar als ik een enter maak in het formulier zie je dat niet op bij mijn blog. Het blijft 1 regel.

Kijk maar op de site. Het laatste bericht heb ik enter> getypt en na enter> heb ik op de enter gedrukt.

Is hier een simpele oplossing voor of zal ik de code hier moeten dumpen?
0
Berichten
832
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bij het invoeren van te tekst, voordat je het in de database zet:
$bericht = nl2br($bericht);
0
Teletext

Lid · Topicstarter

Berichten
359
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thanks smile
De functie $obj->get_content() is toch OOP? (gaat over helemaal iets anders dan me vorige vraagyummie)
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