Page 1 of 1

Pagination & Newbie

Posted: Thu Jan 20, 2005 4:24 am
by fanturex
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

Code: Select all

<?
//Init
$rowsPerPage = 9
$pageUrl = HTTP_SERVER_VARS&#1111;"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&#1111;"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>&nbsp;Page&nbsp;"

//
// Get current page ref (date/time)
//

$UrlArgs=HTTP_SERVER_VARS&#1111;"args"]

//
// Create the pages reference for the bottom of the page.
//
$counter=1
while($row = mysql_fetch_array($resultPageCount)
&#123;

	// 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)&#123;
		if(count($UrlArgs)==2);
			$postDate = $UrlArgs(0);
			$postTime = $UrlArgs(1);
		else;
			$postDate = $row&#1111;"postDATE"];
			$postTime = $row&#1111;"postTIME"];
		endif;
	&#125;

	if(fmod($counter, $rowsPerPage) == 0) &#123;
		$pageRef = $pageRef . "<a href='" . pageUrl . "?date=" . $row&#1111;"postDATE"] . "&time=" . $row&#1111;"postTIME"] ."'>&nbsp;" . pageCounter . "&nbsp</a>";
		pageCounter = pageCounter + 1;
		$counter=1;
	&#125;
	$counter=$counter+1;
&#125;
$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))
&#123;	
   //the format is $variable = $r&#1111;"nameofmysqlcolumn"];
   //modify these to match your mysql table columns
  
    $msgTxt = $row&#1111;"postTXT"];
	$msgId = $row&#1111;"postID"]; 
	$SigName = $row&#1111;"posterNAME"];
	$msgTime = $row&#1111;"postTIME"];
	$msgTitle = $row&#1111;"postTITLE"];
	$msgType = $row&#1111;"postTYPE"];
	$msgDate = $row&#1111;"postDATE"];
	$msgLocation = $row&#1111;"posterLOCATION"];
	$msgYear = $row&#1111;"postYEAR"];
	$msgMonth = $row&#1111;"postMONTH"];
	$msgUrl = $row&#1111;"postAGENDA"];
	$msgUrl1 = $row&#1111;"postMIN"];
	$msgDept = $row&#1111;"postDEPT"];
	$url = $row&#1111;"posterAGENDA"];
	$url = $row&#1111;"postMIN"];
	if ($hr > "11") &#123;
	$x = "12";
	$timetype = "PM";
	$hr = $hr - 12;
	&#125;else&#123;
	$timetype = "AM";
	&#125;
	if (!$msgUrl) &#123;
	$msgUrl = "To be updated";
	&#125;else&#123;
	$stat = $msgUrl;
	$msgUrl = $msgUrl . "";
	&#125;
    if (!$msgUrl1) &#123;
	$msgUrl1 = "To be updated";
	&#125;else&#123;
	$stat = $msgUrl1;
	$msgUrl1 = $msgUrl1 . "";
	&#125;
   //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>");
   &#125;
   if(mysql_num_rows($result) == 0)&#123; 
        echo("The search cannot locate any data at this time");
   &#125;

// Display the page pagination URL's 
echo("<br/> $pageRef");
&#125;
?>
If anyone has suggestions, they would be most welcome.

Many Thanks

Chris

Posted: Thu Jan 20, 2005 4:49 am
by zenabi
This probably won't solve your problem, but just remember it's <br /> and not </br> .

cheers

Posted: Thu Jan 20, 2005 5:13 am
by fanturex
I am very new to PHP so its all still a learning curve.

Cheers

Posted: Thu Jan 20, 2005 9:00 am
by feyd
what's the code at line 127, 128 and 129? I'm not in the mood to play "find the line"