Hej alle!
Jeg har den her kode:
<body>
<form action="index.php" method="post">
<select name="show" size="1">
<?
include("config.php");
$sql = "SELECT id FROM nyheder";
$query = mysql_query($sql);
$num = mysql_num_rows($query);
$average = $num/10;
$pages = ceil($average);
$page_number = 0;
while ($page_number < $pages)
{
$test = $pages-1;
$page_number++;
$show_number = $page_number*10-10;
echo("<option value=\\"".$show_number."\\">".$page_number."</option>");
}
?>
</select>
<input type="submit" value="Vælg"><br>
</form>
<div align="left">
<table border="0" width="506" height="1">
<tr>
<td width="53" height="12">
<b>Nyheder</b></td>
<td width="269" height="12">
<p align="center"><?
if (!$show)
{
$show = 0;
}
include("config.php");
$sql = "SELECT id FROM nyheder";
$query = mysql_query($sql);
$number = mysql_num_rows($query);
echo("Ialt <b>".$number."</b> nyheder.");
?></td>
<td width="131" height="12">
<p align="right"></td>
</tr>
</table>
<?
include ("config.php");
$connect = mysql_query("SELECT * FROM nyheder ORDER BY id DESC LIMIT $show,10") or die(mysql_error());
while($vis = mysql_Fetch_array($connect)) {
?>
</div>
<div align="left">
<table border="0" width="469" height="1">
<tr>
<td width="581" height="12" colspan="3"><hr size="1" color="#000000"></td>
</tr>
<tr>
<td width="109" height="1"><b><? echo "$vis[overskrift]"; ?></b></td>
<td width="351" height="1"></td>
<td width="81" height="1"></td>
</tr>
<tr>
<td width="504" height="77" colspan="2"><? echo "$vis[nyhed]"; ?></td>
</tr>
<tr>
<td width="405" height="1"><i><? echo "$vis[dato]"; ?></i> -
<b><? echo "$vis[forfatter]"; ?></b></td>
<td width="92" height="1"></td>
</tr>
</table>
</div>
<?
}
?>
<p>
<br><br>
<a href='admin.php'>Administration</a>
</body>
Men den gider ikke vise forfatteren og overskriften
Jeg har tjekket min DB om tabellerne var lavet, og det var de. Koden som tilføjer min nyhed ser sådan ud:
<?
$nyhed = nl2br($_POST[nyhed]);
include ("config.php");
$dato = date('d/m/Y H:i:s');
mysql_query("INSERT INTO nyheder (overskrift, nyhed, forfatter, dato, hits) VALUES ('$overskrift', '$nyhed', '$forfatter', '$dato', '0')") OR DIE (mysql_error());
?>
Nyheden er tilføjet! :) Klik <A HREF="index.php">her</A> for at komme tilbage til nyhederne
Håber virkelig nogen kan hjælpe