ok, ich weiss nicht genau, ob es das nun ist, was es sein soll (komischer satzbau), aber hier ist es...
diesen code packst du auf die hauptseite, um deinen kram anzuzeigen, das ganze is noch ein wenig primitiv, aber naja...
(dateiname: index.php3)
Code:
<?
$sel = "SELECT * FROM artikel ORDER BY id DESC LIMIT 2";
$que = mysql_query($sel, $connection);
while ($row = mysql_fetch_object($que)) {
//Jetzt kommt eine Sample Tabelle, die ich dem Aufwand halber einfach mal so kopiert hab
?>
<table width="250" cellspacing="0" cellpadding="0" border="0">
<tr>
<td height="1" align="left" valign="middle" bgcolor="#000000">
<font color="#FFFFFF" face="Arial, Helvetica, sans-serif" size="1"><img src="kopf-links.gif" width="17" height="14" align="absmiddle">
<? echo $row->titel // Gibt die Überschrift der News aus ?>
</font></td>
<td align="left" valign="top" rowspan="2" width="1" colspan="2">
<?
if ($row->picsrc > "") {
?>
<img src="<? echo $row->picsrc // Gibt das Bild für den Artikel aus ?>" align="left" alt="Bild">
<?
} else {
?><img src="standartbild.jpg" alt="Bild der Headline"><?
}
?></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#ABABAB" height="55" width="170">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="1">(<? echo $row->user // Wer hat die News geschrieben?>)
<? echo ereg_replace("\n", "<br>", $row->einleitung) // Gibt die Einleitung aus, die auch nochmal bei den richtigen News gezeigt wird ?>
</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#ABABAB" colspan="3">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td bgcolor="#000000" width="20" valign="bottom" align="left></td>
<td bgcolor="#000000" valign="top">
<font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="1" color="#FFFFFF"><strong><img src="minipfeil.gif" width="4" height="6" align="bottom" border="0"> <a href="index.php3?site=artshow.php3&artid=<? echo $row->id ?>">MORE</a><img src="blank.gif" width="10" height="10"><img src="minipfeil.gif" width="4" height="6" align="bottom" border="0"> <a href="index.php3?site=comreader.php3&artid=<? echo $row->id ?>">COMMENTS</a></strong></font></td>
<td bgcolor="#000000" background="kopf.jpg" width="20" valign="bottom" align="right"></td>
</tr>
</table>
</td>
</tr>
</table>
mit diesem code kannst du die (ich nenn sie immer so gern so) aufreisser auf der hauptseite anzeigen, ich würd aber noch den tabellencode verändern, damit das ganze deiner seite entsprechend aussieht.
so, nun kommen wir zum news anzeigen, in voller länge.
kommentarfunktion is noch drin, aber kannst du leicht raushauen
(name der datei: artshow.php3)
Code:
<?
if ($artid > "") {
$sel = "SELECT * FROM artikel WHERE id = ".$artid;
$que = mysql_query($sel, $connection);
$num = mysql_num_rows($que);
}
if ($num == 1) {
while ($row = mysql_fetch_object($que)) {
$art_title = $row->titel;
$art_start = $row->einleitung;
$art_text = $row->hauptteil;
$art_user = $row->user;
}
?>
<table width="95%" border="0" cellspacing="0" cellpadding="10" align="center">
<tr>
<td>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"><b>
<? echo $art_title ?>
</b></font></p>
<table border="0" cellspacing="0" cellpadding="0" align="center" width="100%">
<tr>
<td valign="top">
<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
<td height="3" align="left" valign="middle" class="startaufmacherheadline" background="kopf.jpg">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td bgcolor="#000000" background="kopf.jpg" width="20" valign="bottom" align="left"><img src="kopf-links.gif" width="17" height="14"></td>
<td bgcolor="#000000" background="kopf.jpg" align="center">
<font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="1" color="#FFFFFF"><strong>
<? echo $art_title ?>
</strong></font></td>
<td bgcolor="#000000" background="kopf.jpg" width="20" valign="bottom" align="right"><img src="kopf-rechts.gif" width="17" height="14"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#ABABAB">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td>
<p><font face="Arial, Helvetica, sans-serif" size="1" color="#000000">
<? echo ereg_replace("\n", "<br>", $art_start) ?>
</font></p>
<p><font face="Arial, Helvetica, sans-serif" size="1" color="#000000">
<?
echo str_replace("\n", "<br>", $art_text);
?>
</font></p>
<p align="right"><font face="Arial, Helvetica, sans-serif" size="1" color="#000000">Autor:
<b>
<?
echo $art_user;
?>
</b><br>
Verfasst: <b>
<?
echo date("d.m.Y", $art_time);
?>
-
<?
echo date("H:i", $art_time);
?>
</b></font></p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td bgcolor="#000000" background="kopf.jpg" width="20" valign="bottom" align="left"><img src="unten-links.gif" width="17" height="14"></td>
<td bgcolor="#000000" background="kopf.jpg"><img src="blank.gif" width="10" height="10"></td>
<td bgcolor="#000000" background="kopf.jpg" width="20" valign="bottom" align="right"><img src="unten-rechts.gif" width="17" height="14"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
} else {
error_msgs(5, $connection);
}
?>
<br>
so, kommentare hab ich schon rausgeschmissen. jetzt fehlt noch ne datenbankverbindung. ich mach sowas immer ganz gerne bereits im head, darüber regen sich html-fanatiker und syntax-freaks immer herrlich auf...
Code:
<?php
include("config.mysql.php3");
$connection = mysql_connect($server, $user, $pass);
mysql_select_db($db);
?>
die config.mysql.php3 sieht bei mir so aus...
(dateiname: config.mysql.php3)
Code:
<?
$server = "dein mysql server host";
$user = "dein mysql user";
$pass = "dein mysql pass";
$db = "die datenbank";
?>
so, nun fehlt ja nur noch die dump für den myadmin...
Code:
CREATE TABLE artikel (
id int(50) NOT NULL auto_increment,
user varchar(50) DEFAULT 'LA' NOT NULL,
titel varchar(55) NOT NULL,
einleitung longtext NOT NULL,
hauptteil longtext NOT NULL,
timestamp int(10) DEFAULT '1' NOT NULL,
picsrc varchar(150) NOT NULL,
PRIMARY KEY (id)
);
# --------------------------------------------------------
#
# Tabellenstruktur f�r Tabelle 'comments'
#
CREATE TABLE comments (
id int(50) NOT NULL auto_increment,
artid int(50) DEFAULT '0' NOT NULL,
titel varchar(150) NOT NULL,
text longtext NOT NULL,
user varchar(100) DEFAULT '0' NOT NULL,
timestamp int(10) DEFAULT '0' NOT NULL,
type varchar(10) NOT NULL,
PRIMARY KEY (id)
);
wobei ich nicht weiss, ob comments gebraucht werden.
so, ich hoffe, das hilft dir hier weiter