Pagination & Newbie
Posted: Thu Jan 20, 2005 4:24 am
Hello all I trying to add pagination to an existing working script, at present it gives the following error:
Parse error: parse error, unexpected T_VARIABLE in C:\inetpub\wwwroot\iso\search.php on line 128
If anyone has any time or suggestions, this is the code for this php script
If anyone has suggestions, they would be most welcome.
Many Thanks
Chris
Parse error: parse error, unexpected T_VARIABLE in C:\inetpub\wwwroot\iso\search.php on line 128
If anyone has any time or suggestions, this is the code for this php script
Code: Select all
<?
//Init
$rowsPerPage = 9
$pageUrl = HTTP_SERVER_VARSї"SCRIPT_URI"]
$pageCounter = 1
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","","");
//select which database you want to edit
mysql_select_db("meetings");
$search=$_POSTї"search"];
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
// The whole page ref and pagination should only be done once!!, at this time it is being done every time
// the page is being referenced! I suppose you could put it in a hidden form field and check for its existance,
// otherwise run the code below!!
$resultPageCount = mysql_query("SELECT postID, postDATE, postTIME FROM `comtbl` WHERE `postTYPE` LIKE '%$search%' OR `postDEPT` LIKE '%$search%' order by postDATE, postTIME")
$pages = mysql_num_rows($resultPageCOunt) / rowsPerPage;
// Build a reference string
$pageRef="<p> Page "
//
// Get current page ref (date/time)
//
$UrlArgs=HTTP_SERVER_VARSї"args"]
//
// Create the pages reference for the bottom of the page.
//
$counter=1
while($row = mysql_fetch_array($resultPageCount)
{
// Check to see if the post date/time url refs have been initialised,
// otherwise, init them with the first ref!
if($counter==1 and $pageCounter==1){
if(count($UrlArgs)==2);
$postDate = $UrlArgs(0);
$postTime = $UrlArgs(1);
else;
$postDate = $rowї"postDATE"];
$postTime = $rowї"postTIME"];
endif;
}
if(fmod($counter, $rowsPerPage) == 0) {
$pageRef = $pageRef . "<a href='" . pageUrl . "?date=" . $rowї"postDATE"] . "&time=" . $rowї"postTIME"] ."'> " . pageCounter . " </a>";
pageCounter = pageCounter + 1;
$counter=1;
}
$counter=$counter+1;
}
$pageRef = pageRef . "</p>";
// End of pageination, get the page reference from the url
// Back to your query and page building, Please check the date range syntax "and postDATE >= " . $postDate . ".
$result = mysql_query("SELECT * FROM `comtbl`
WHERE
postDATE >= '" . $postDATE . "'
AND postTime >= '" . $postTIME . "'
`postTYPE` LIKE '%$search%'
OR `postDEPT` LIKE '%$search%'
order by postDATE, postTIME limit 9")
//grab all the content
while($row = mysql_fetch_array($result))
{
//the format is $variable = $rї"nameofmysqlcolumn"];
//modify these to match your mysql table columns
$msgTxt = $rowї"postTXT"];
$msgId = $rowї"postID"];
$SigName = $rowї"posterNAME"];
$msgTime = $rowї"postTIME"];
$msgTitle = $rowї"postTITLE"];
$msgType = $rowї"postTYPE"];
$msgDate = $rowї"postDATE"];
$msgLocation = $rowї"posterLOCATION"];
$msgYear = $rowї"postYEAR"];
$msgMonth = $rowї"postMONTH"];
$msgUrl = $rowї"postAGENDA"];
$msgUrl1 = $rowї"postMIN"];
$msgDept = $rowї"postDEPT"];
$url = $rowї"posterAGENDA"];
$url = $rowї"postMIN"];
if ($hr > "11") {
$x = "12";
$timetype = "PM";
$hr = $hr - 12;
}else{
$timetype = "AM";
}
if (!$msgUrl) {
$msgUrl = "To be updated";
}else{
$stat = $msgUrl;
$msgUrl = $msgUrl . "";
}
if (!$msgUrl1) {
$msgUrl1 = "To be updated";
}else{
$stat = $msgUrl1;
$msgUrl1 = $msgUrl1 . "";
}
//display the row
echo("<p>Meeting Type: $msgType $msgTxt<div align=centre>
Location: $msgLocation </br>
Chair: $SigName $msgTitle </br>
Department: $msgDept </br>
Meeting Date: $msgDate </br>
Meeting Time: $msgTime </br>
Meeting Agenda: <a href='$msgUrl'>$msgUrl</a> </br>
Meeting Minutes: <a href='$msgUrl1'>$msgUrl1</a>
<hr></div></p>");
}
if(mysql_num_rows($result) == 0){
echo("The search cannot locate any data at this time");
}
// Display the page pagination URL's
echo("<br/> $pageRef");
}
?>Many Thanks
Chris