1
pipwax
External Database Driven Pages
  • 2006/4/19 23:45

  • pipwax

  • Not too shy to talk

  • Posts: 132

  • Since: 2005/9/12


I am trying to create a method to display my events on www.sk8photos.com > events. I have created a database page www.sk8photos.com/show_records.php can I copy the code and paste it into a block to get it to work?
pipwax1@bellsouth.net
Quote:
To win in life one must be fluid like water, taking the shape needed to prevail


aspring IT Professional

2
peterr
Re: External Database Driven Pages
  • 2006/4/20 2:28

  • peterr

  • Just can't stay away

  • Posts: 518

  • Since: 2004/8/5 9


Short answer, ..yes.

See Can I include my own HTML pages in xoops? , which is for a html page, your php page is much the same ......

<?php
include("path/to/mainfile.php");
include(
XOOPS_ROOT_PATH."/header.php");

// All the content of your current php file goes here

include(XOOPS_ROOT_PATH."/footer.php");
?>


(I _think_ ??)
NO to the Microsoft Office format as an ISO standard.
Sign the petition

3
pipwax
Re: External Database Driven Pages
  • 2006/4/21 0:21

  • pipwax

  • Not too shy to talk

  • Posts: 132

  • Since: 2005/9/12


Quote:

peterr wrote:
Short answer, ..yes.

See Can I include my own HTML pages in xoops? , which is for a html page, your php page is much the same ......

<?php
include("path/to/mainfile.php");
include(
XOOPS_ROOT_PATH."/header.php");

// All the content of your current php file goes here

include(XOOPS_ROOT_PATH."/footer.php");
?>


(I _think_ ??)


I tryied that but however, I guess I forgot to tell you that I made my database page using Dreamweaver and as you see it works fins as a standalone but i can't get XOOPS to wrap around this database page.

=========================My code=========================

<?php require_once('Connections/SkateEvents.php'); ?>
<?php
$maxRows_allevents = 5;
$pageNum_allevents = 0;
if (isset($_GET['pageNum_allevents'])) {
$pageNum_allevents = $_GET['pageNum_allevents'];
}
$startRow_allevents = $pageNum_allevents * $maxRows_allevents;

mysql_select_db($database_SkateEvents, $SkateEvents);
$query_allevents = "SELECT * FROM events ORDER BY `Date` ASC";
$query_limit_allevents = sprintf("%s LIMIT %d, %d", $query_allevents, $startRow_allevents, $maxRows_allevents);
$allevents = mysql_query($query_limit_allevents, $SkateEvents) or die(mysql_error());
$row_allevents = mysql_fetch_assoc($allevents);

if (isset($_GET['totalRows_allevents'])) {
$totalRows_allevents = $_GET['totalRows_allevents'];
} else {
$all_allevents = mysql_query($query_allevents);
$totalRows_allevents = mysql_num_rows($all_allevents);
}
$totalPages_allevents = ceil($totalRows_allevents/$maxRows_allevents)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Events Page</title>
</head>

<body>
<table width="800" border="1" align="center" cellpadding="5" cellspacing="5">
<tr>
<td width="82"><div align="center">Date</div></td>
<td width="136"><div align="center">Events</div></td>
<td width="124"><div align="center">Host</div></td>
<td width="177"><div align="center">More info</div></td>
<td width="34"><div align="center">Host id</div></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_allevents['Date']; ?></td>
<td><?php echo $row_allevents['Events']; ?></td>
<td><?php echo $row_allevents['Host']; ?></td>
<td><a target="_blank" href="http://sk8photos.com/xoop/html/modules/page/images/flyers/"><?php echo $row_allevents['More info']; ?>Click Here</a></td>
<td><?php echo $row_allevents['Host id']; ?></td>
</tr>
<?php } while ($row_allevents = mysql_fetch_assoc($allevents)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($allevents);
?>
=========================end code======================
pipwax1@bellsouth.net
Quote:
To win in life one must be fluid like water, taking the shape needed to prevail


aspring IT Professional

4
peterr
Re: External Database Driven Pages
  • 2006/4/21 0:35

  • peterr

  • Just can't stay away

  • Posts: 518

  • Since: 2004/8/5 9


From first looking at the code, the while staement should be up the top somewhere shouldn't it ? Also, there is no closing brace on the while statement ?

I wouldn't use Dreamweaver to create php code either, I've heard some horrar stories.

edit: .. oops, I didn't so the php 'do'. lol

When you try wrapping the XOOPS code around it, what does it do, any error messages ?
NO to the Microsoft Office format as an ISO standard.
Sign the petition

5
pipwax
Re: External Database Driven Pages
  • 2006/4/21 1:01

  • pipwax

  • Not too shy to talk

  • Posts: 132

  • Since: 2005/9/12


I get a blank page wraped in Xoops.
pipwax1@bellsouth.net
Quote:
To win in life one must be fluid like water, taking the shape needed to prevail


aspring IT Professional

6
peterr
Re: External Database Driven Pages
  • 2006/4/21 1:15

  • peterr

  • Just can't stay away

  • Posts: 518

  • Since: 2004/8/5 9


What does your php error log say ?
NO to the Microsoft Office format as an ISO standard.
Sign the petition

7
pipwax
Re: External Database Driven Pages
  • 2006/4/21 14:27

  • pipwax

  • Not too shy to talk

  • Posts: 132

  • Since: 2005/9/12


I am not sure what that means. However, This simple page works so why can't i just use the include statement?

<?php require_once('Connections/SkateEvents.php'); ?>
<?php
$maxRows_allevents = 5;
$pageNum_allevents = 0;
if (isset($_GET['pageNum_allevents'])) {
$pageNum_allevents = $_GET['pageNum_allevents'];
}
$startRow_allevents = $pageNum_allevents * $maxRows_allevents;

mysql_select_db($database_SkateEvents, $SkateEvents);
$query_allevents = "SELECT * FROM events ORDER BY `Date` ASC";
$query_limit_allevents = sprintf("%s LIMIT %d, %d", $query_allevents, $startRow_allevents, $maxRows_allevents);
$allevents = mysql_query($query_limit_allevents, $SkateEvents) or die(mysql_error());
$row_allevents = mysql_fetch_assoc($allevents);

if (isset($_GET['totalRows_allevents'])) {
$totalRows_allevents = $_GET['totalRows_allevents'];
} else {
$all_allevents = mysql_query($query_allevents);
$totalRows_allevents = mysql_num_rows($all_allevents);
}
$totalPages_allevents = ceil($totalRows_allevents/$maxRows_allevents)-1;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php include('show_records.php'); ?>
</body>
</html>
pipwax1@bellsouth.net
Quote:
To win in life one must be fluid like water, taking the shape needed to prevail


aspring IT Professional

8
pipwax
Re: External Database Driven Pages
  • 2006/4/21 15:04

  • pipwax

  • Not too shy to talk

  • Posts: 132

  • Since: 2005/9/12


Ok guys and gals I have a code that works, and now I am looking for constructive comments.

++++++++++++++++here's the code++++++++++++++++++++++++++++
<?php require_once('Connections/SkateEvents.php'); ?>
<?php
include("mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
?>

<?php
$maxRows_allevents = 5;
$pageNum_allevents = 0;
if (isset($_GET['pageNum_allevents'])) {
$pageNum_allevents = $_GET['pageNum_allevents'];
}
$startRow_allevents = $pageNum_allevents * $maxRows_allevents;

mysql_select_db($database_SkateEvents, $SkateEvents);
$query_allevents = "SELECT * FROM events ORDER BY `Date` ASC";
$query_limit_allevents = sprintf("%s LIMIT %d, %d", $query_allevents, $startRow_allevents, $maxRows_allevents);
$allevents = mysql_query($query_limit_allevents, $SkateEvents) or die(mysql_error());
$row_allevents = mysql_fetch_assoc($allevents);

if (isset($_GET['totalRows_allevents'])) {
$totalRows_allevents = $_GET['totalRows_allevents'];
} else {
$all_allevents = mysql_query($query_allevents);
$totalRows_allevents = mysql_num_rows($all_allevents);
}
$totalPages_allevents = ceil($totalRows_allevents/$maxRows_allevents)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Events Page</title>
</head>

<body>
<table width="800" border="1" align="center" cellpadding="5" cellspacing="5">
<tr>
<td width="82"><div align="center">Date</div></td>
<td width="136"><div align="center">Events</div></td>
<td width="124"><div align="center">Host</div></td>
<td width="177"><div align="center">More info</div></td>
<td width="34"><div align="center">Host id</div></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_allevents['Date']; ?></td>
<td><?php echo $row_allevents['Events']; ?></td>
<td><?php echo $row_allevents['Host']; ?></td>
<td><a target="_blank" href="http://sk8photos.com/xoop/html/modules/page/images/flyers/"><?php echo $row_allevents['More info']; ?>Click Here</a></td>
<td><?php echo $row_allevents['Host id']; ?></td>
</tr>
<?php } while ($row_allevents = mysql_fetch_assoc($allevents)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($allevents);
include(XOOPS_ROOT_PATH."/footer.php");

?>
+++++++++++++++++++++end code++++++++++++++++++++++++++++++

I had to load the page up in the directory xoops/html/show_records.php I will have to tweak the page and refer to the css file with in the theme but how will I like the page to the navigation to make it look all the same. I also need to fix the link so that each link will point to a flyer.

View results here

Thanks guys.
pipwax1@bellsouth.net
Quote:
To win in life one must be fluid like water, taking the shape needed to prevail


aspring IT Professional

9
peterr
Re: External Database Driven Pages
  • 2006/4/22 0:59

  • peterr

  • Just can't stay away

  • Posts: 518

  • Since: 2004/8/5 9


Quote:

pipwax wrote:
I am not sure what that means.


Run a php script with the phpinfo() function in it, and you will see an entry "error_log", that is where your php error log is.
NO to the Microsoft Office format as an ISO standard.
Sign the petition

10
peterr
Re: External Database Driven Pages
  • 2006/4/22 1:10

  • peterr

  • Just can't stay away

  • Posts: 518

  • Since: 2004/8/5 9


Quote:

pipwax wrote:
Ok guys and gals I have a code that works, and now I am looking for constructive comments.


1. There will be more load on the server 'turning php on and off' unecessarily. The first few lines of code need to be replaced by ...

<?php
include("mainfile.php");
include(
XOOPS_ROOT_PATH."/header.php");

require_once(
'Connections/SkateEvents.php');
$maxRows_allevents 5;


2. Remove this code at the top ..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
title>Events Page</title>
</
head>
<
body>


and this code at the bottom, ..

</body>
</
html>


it's not needed.
NO to the Microsoft Office format as an ISO standard.
Sign the petition

Login

Who's Online

162 user(s) are online (97 user(s) are browsing Support Forums)


Members: 0


Guests: 162


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jun 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits