I am having a few probs with this script and would love to get it finished! If anyone could help it would be greatly appreciated!
I have a page with a number of topics on it and the links are set out as bellow!
the type and cat are supplied by the page before this!
I am using this page to display the results
//////////////////////////////////////////
results page
/////////////////////////////////////////
////////////////////////////////////////////////
I unable to get any variables on the page links like 1,2 or next and previous. I need the variables concatinated otherwise when it goes to the next page it just displays * the results.
Is there anyone that can help me?
plz plz plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz!
Thanks
Gman
I have a page with a number of topics on it and the links are set out as bellow!
PHP-Code:
<a class=menu href="eventlist.php?category=hr127&type=<?php echo ($type); ?>&eventcat=<?php echo ($topic); ?>">Finance
& Accountancy</a>
I am using this page to display the results
//////////////////////////////////////////
results page
/////////////////////////////////////////
PHP-Code:
<?php
global $HTTP_GET_VARS;
$page = $HTTP_GET_VARS["page"];
$eventcat1 = $HTTP_GET_VARS["eventcat"];
require ("class.recnavevnt.php");
$headerTemplate = "<h5>your search returned these results</h5>";
$headerTemplate .= "<table width='510' border='1' bordercolor='silver' cellspacing='0' cellpadding='2' style=border-collapse: collapse>";
$headerTemplate .= "<tr>";
$headerTemplate .= "<td width='15%' height='20' bgcolor='Silver' align='center' nowrap>";
$headerTemplate .= " <font face='verdana' size='1' color='DarkBlue'><b>";
$headerTemplate .= " Event Type ";
$headerTemplate .= " </b></font>";
$headerTemplate .= "</td>";
$headerTemplate .= "<td width='85%' height='20' bgcolor='Silver' align='center'>";
$headerTemplate .= " <font face='verdana' size='1' color='DarkBlue'><b>";
$headerTemplate .= " Event Info";
$headerTemplate .= " </b></font>";
$headerTemplate .= "</td>";
$headerTemplate .= "</tr>";
$bodyTemplate = "<tr>";
$bodyTemplate .= "<td width='15%' bgcolor='white' align='center'>";
$bodyTemplate .= " <font face='verdana' size='1' color='darkblue'><b>";
$bodyTemplate .= " <| row2 |>";
$bodyTemplate .= "</b> </font>";
$bodyTemplate .= "</td>";
$bodyTemplate .= "<td width='85%' bgcolor='white' height='50'>";
$bodyTemplate .= " <p style='margin-left:10'>";
$bodyTemplate .= " <a class=menu href='eventinfo.php?eventid=<| row0 |>'>";
$bodyTemplate .= " <b><font face='verdana' size='1' color='DarkBlue'>Event Title: </font><u><| row3 |></u></b>";
$bodyTemplate .= " </a>";
$bodyTemplate .= " </font>";
$bodyTemplate .= " <br> ";
$bodyTemplate .= " <font face='verdana' size='1' color='black'>";
$bodyTemplate .= " <br><b>Event Start Date: </b><| row7 |>";
$bodyTemplate .= " </font>";
$bodyTemplate .= " <font face='verdana' size='1' color='black'>";
$bodyTemplate .= " <br><b>Event Country: </b><| row8 |>";
$bodyTemplate .= " </font>";
$bodyTemplate .= " <font face='verdana' size='1' color='black'>";
$bodyTemplate .= " <br><b>Event Details: </b><| row4 |>";
$bodyTemplate .= " </font>";
$bodyTemplate .= " <br> ";
$bodyTemplate .= " <font face='verdana' size='1' color='black'>";
$bodyTemplate .= " <br><font face='verdana' size='1' color='red'><b>Full Event Details: </font><a class=menu href='fulevntdet.php?eventid=<| row0 |>'>view </a></b>";
$bodyTemplate .= " </font>";
$bodyTemplate .= "</td>";
$bodyTemplate .= "</tr>";
$s = mysql_connect("localhost", "root", "");
$d = mysql_select_db("workinfo", $s);
$r = new RecNav($s, "SELECT * FROM uevents where eventcat1 like '%$category%' and eventtype like '%$type%' and eventcat like '%$eventcat%' or eventcat2 like '%$category%' and eventtype like '%$type%' and eventcat like '%$eventcat%' or eventcat3 like '%$category%' and eventtype like '%$type%' and eventcat like 'eventcat' ORDER BY eventid ASC", $bodyTemplate, $headerTemplate, "",5);
echo $r->ShowRecs($page);
echo ($category);
echo ($type);
echo ($eventcat1);
?>
//////////////////////////////////////////////
above echoed variables are displayed in the page but are not in the url!
///////////////////////////////////////////
this is the class page it requires.
///////////////////////////////////////////
<?php
global $HTTP_GET_VARS;
$page = $HTTP_GET_VARS["page"];
$eventcat1 = $HTTP_GET_VARS["eventcat"];
// Default number of records
define("DEFAULT_NUM_RECS", 10);
define("DEFAULT_TEMPLATE_HEADER", "<table width='100%' cellspacing='0' cellpadding='0' border='0'><tr><td width='10%' height='21' bgcolor='black' align='center'><font color='white' face='verdana' size='1'><b>Id</b></font></td><td width='80%' height='21' bgcolor='black'><font color='white' face='verdana' size='1'><b>Description</b></font></td><td width='10%' height='21' bgcolor='black' align='center'><font color='white' face='verdana' size='1'><b>Price</b></font></td></tr>");
define("DEFAULT_TEMPLATE", "<tr><td width='10%' height='21' align='center'><font face='verdana' size='1' color='darkblue'><b><| row0 |></b></font></td><td width='80%' height='21'><font face='verdana' size='1' color='black'><| row1 |></font></td><td width='10%' height='21'><font face='verdana' size='1' color='red'>$<| row2 |></font></td></tr>");
define("DEFAULT_TEMPLATE_FOOTER", "</table>");
class RecNav
{
function RecNav(&$LinkIdentifier, $Query, $Template=DEFAULT_TEMPLATE, $TemplateHeader=DEFAULT_TEMPLATE_HEADER, $TemplateFooter=DEFAULT_TEMPLATE_FOOTER, $RecsPerPage=DEFAULT_NUM_RECS)
{
// Validate constructor parameters
if(!@mysql_query("SELECT 1", $LinkIdentifier))
{ die("MYSQL link identifier is invalid"); }
else
{
$this->__linkId = $LinkIdentifier;
}
if(!ereg("^SELECT", $Query))
{ die("Invalid query: query must start with 'SELECT'"); }
else
{ $this->__query = $Query; }
if($Template == "")
{ $this->__template = DEFAULT_TEMPLATE; }
else
{ $this->__template = $Template; }
if($TemplateHeader == "")
{ $this->__templateHeader = DEFAULT_TEMPLATE_HEADER; }
else
{ $this->__templateHeader = $TemplateHeader; }
if($TemplateFooter == "")
{ $this->__templateFooter = DEFAULT_TEMPLATE_FOOTER; }
else
{ $this->__templateFooter = $TemplateFooter; }
if(!is_numeric($RecsPerPage) || $RecsPerPage < 1)
{ $this->__recsPerPage = DEFAULT_NUM_RECS; }
else
{ $this->__recsPerPage = $RecsPerPage; }
}
function ShowRecs($Page=1)
{
// Using the classes variables and the $Page variable,
// the ShowRecs function will query the database and
// return the records based on the $__template variable.
$finalOutput = $this->__templateHeader;
if($Page <= 1)
{
$Page = 1;
$query = $this->__query . " LIMIT 0, " . $this->__recsPerPage;
}
else
{ $query = $this->__query . " LIMIT " . (($Page-1) * $this->__recsPerPage) . ", " . $this->__recsPerPage; }
$result = mysql_query($query);
$hasRecords = mysql_num_rows($result) == 0 ? false : true;
if($hasRecords)
{
// At least one records returned from the query
while($row = mysql_fetch_row($result))
{
$newRow = $this->__template;
for($i = 0; $i < mysql_num_fields($result); $i++)
{ $newRow = str_replace("<| row" . $i . " |>", $row[$i], $newRow); }
$finalOutput .= $newRow;
}
}
else
{
// No records returned from the query
$newRow = $this->__template;
$newRow = string_replace("<| row0 |>", "No records found", $newRow);
// Replace all template tags with
$newRow = ereg_replace("<| row[0-9] |>", " ", $newRow);
$finalOutput .= $newRow;
}
$finalOutput .= $this->__templateFooter;
// Build the recordset paging links
$numTotalRecs = mysql_num_rows(mysql_query($this->__query));
$numPages = ceil($numTotalRecs / $this->__recsPerPage);
$nav = "";
// Can we have a link to the previous page?
if($Page > 1)
$nav .= "<a href='$PHP_SELF?page=" . ($Page-1) . "&category=" . $category . "&type=" . $type . "&eventcat=" . $eventcat1 . "'> << Prev</a> |";
for($i = 1; $i < $numPages+1; $i++)
{
if($Page == $i)
{
// Bold the page and dont make it a link
$nav .= " <b>$i</b> |";
}
else
{
// Link the page
$nav .= " <a href='$PHP_SELF?page=" . $i . "&category=" . $category . "&type=" . $type . "&eventcat=" . $eventcat1 . "'>$i</a> |";
}
}
// Can we have a link to the next page?
if($Page < $numPages)
$nav .= " <a href='$PHP_SELF?page=" . ($Page+1) . "&category=" . $category . "&type=" . $type . "&eventcat=" . $eventcat1 . "'> Next >></a>";
// Strip the trailing pipe if there is one
// $nav = ereg_replace("$|", "", $nav);
$finalOutput .= "<div align='right'><font face='verdana' size='1'><br>Pages: $nav</font></div>";
return $finalOutput;
}
var $__linkId;
var $__dbType;
var $__query;
var $__template;
var $__templateHeader;
var $__templateFooter;
var $__recsPerPage;
}
?>
I unable to get any variables on the page links like 1,2 or next and previous. I need the variables concatinated otherwise when it goes to the next page it just displays * the results.
Is there anyone that can help me?
plz plz plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz!
Thanks
Gman
Kommentar