MyBB Community Forums

Full Version: kind of portal.php problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I will try to keep this as short as possible.
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>
      <?
}
?>
      &nbsp;</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>
      <?
}
?>
      &nbsp;</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>
          <?
}
?>
          &nbsp;</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>
          <?
}
?>
          &nbsp;</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
I can see a MyBB template but your php code isn't linked to MyBB like it is not a part of mybb as a result those variables there won't work.
but the code is totally seperate from mybb, i just want it to be displayed on a page that looks similar to mybb
You still need to include it in MyBB
Read here
so i need
<?php

define('IN_MYBB', 1); // (1a)
require "./global.php"; // (1b)

add_breadcrumb("Rules page", "rules.php"); // (2)

eval("\$rules = \"".$templates->get("rules")."\";"); // (3)
output_page($rules); // (4)
?>
to implament that part into my php section? obviously changing riles to articles?
Remember your templates should be in MyBB template.. the name of the template should be use in the templates->get();
I think i may have gon wrong here, ive read your post and have come up with the below code, it displays the articles but doesnt format it at all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Gaming Forums | Gaming Articles</title>
<?php define('IN_MYBB', 1); // (1a) require "./global.php"; // (1b) add_breadcrumb("Articles", "articles.php"); // (2) eval("\$articles = \"".$templates-

>get("articles")."\";"); // (3) output_page($articles); // (4) ?>
</head>
<body>
<br>
<?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>
      <?
}
?>
      &nbsp;</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>
      <?
}
?>
      &nbsp;</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>
          <?
}
?>
          &nbsp;</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>
          <?
}
?>
          &nbsp;</span></div></td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>

and agai this is what i have under the articles section on the acp:
<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->gamesection}</title>
{$headerinclude}
</head>
<body>

{$header}</td>
</tr>


{$games_footer}
{$footer}
</body>
</html>

I really do appreciate the help
i cant do this if i was to offer $10 would someone be able to do it for me?

Cheers
nobody interested?
$10 for something that would take very long for someone who knows what theyre doing - and helping someone in need out