2007-03-27, 04:55 PM
I will try to keep this as short as possible.
I have a page (articles/articles.php) which has the following code:
However i want it to have a script in it which loads up a database, the script is as below:
I have a page (articles/articles.php) which has the following code:
<html>
<head>
<title>{$mybb->settings[bbname]}</title>
{$headerinclude}
</head>
<body>
{$header}
<br />
<br/>
{$footer}
</body>
</html>
However i want it to have a script in it which loads up a database, the script is as below:
<?php
// Include the config
include "config.php";
// Get current page number
$page = $_GET["page"];
// Do the limit math
if(!isset($page)) { // This variable is set to zero for the first page
$page = 0;
}
$eu = ($page - 0);
$limit = 30;
$past = $eu - $limit;
$next = $eu + $limit;
?>
<table width="55%" border="0" align="center" cellpadding="5" cellspacing="5">
<tr>
<td height="20"><div align="center"><span class="style6">
<?
if ($page < 10) {
?>
<b>Past Page</b>
<?
} else {
?>
<b><a href="?page=<? echo $past ?>">Past Page</a></b>
<?
}
?>
</span></div></td>
<td><div align="center"><span class="style1">
<?
if ($page > 3000) {
?>
<b>Next Page</b>
<?
} else {
?>
<b><a href="?page=<? echo $next ?>">Next Page</a></b>
<?
}
?>
</span></div></td>
</tr>
<tr>
<td height="20" colspan="2"><?
$query = "SELECT * FROM cad_content WHERE catid='105' limit $eu, $limit ";
// store the record of the "example" table into $row
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$title = $row['title'];
$id = $row['id'];
?>
<a href="show.php?id=<? echo $id ?>"><? echo $title ?></a> <br />
<?
}
?></td>
</tr>
<tr>
<td height="20" colspan="2"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20"><div align="center"><span class="style6">
<?
if ($page < 10) {
?>
<b>Past Page</b>
<?
} else {
?>
<b><a href="?page=<? echo $past ?>">Past Page</a></b>
<?
}
?>
</span></div></td>
<td><div align="center"><span class="style1">
<?
if ($page > 3000) {
?>
<b>Next Page</b>
<?
} else {
?>
<b><a href="?page=<? echo $next ?>">Next Page</a></b>
<?
}
?>
</span></div></td>
</tr>
</table></td>
</tr>
</table>
the scipt basically loads up the titles of the database articles and displays just the titles as links which link to the full article, i want the script to work on the actual site however they dont seem to work properly together i always get sql errors any help would be appreciated