Jump to content

Need help using FireScope Grid (PDO issues)


timcadieux

Recommended Posts

I was able to get the FireScope Grid to work fine on my WAMP but when I uploaded it I was told that the driver was not loaded.!  Argh.

 

I'm not a PhP coder and I'm struggling to convert the PDO to code that I can understand and use.

 

Any help would be appreciated.

<?php
include_once("settings.php");


ini_set("memory_limit","256M");

$dbh = new PDO('mysql:host=localhost;dbname=***','***','***');

if (isset($_REQUEST['firescope_grid'])) {
try {

	$sql = "SELECT tblnames.ID, tblnames.fldsurname, tblnames.fldfirstnameinitial, tblrank.fldrank, tblservice.fldservice, tblunit.fldunit, 
	tblcountry.fldcountry, tblcemetery.fldcemetery,
	 'Details' as lnk_details
		FROM tblnames
			LEFT JOIN (
				tblrank,
				tblservice,
				tblunit,
				tblcountry,
				tblcounty,
				tblcemetery

			) ON (
				tblrank.ID = tblnames.tblrank_ID AND
				tblservice.ID = tblnames.tblservice_ID AND
				tblunit.ID = tblnames.tblunit_ID AND
				tblcountry.ID = tblnames.tblcountry_ID AND
				tblcounty.ID = tblnames.tblcounty_ID AND
				tblnames.tblcemetery_ID = tblcemetery.ID 
			)
			WHERE 1=1 

			";	



	if ($_REQUEST['firescope_grid_filterCol'] == 0 && strlen($_REQUEST['firescope_grid_filterText']) > 0) {
		$sql.=" AND fldsurname LIKE '%".$_REQUEST['firescope_grid_filterText']."%'";
	}
	else if ($_REQUEST['firescope_grid_filterCol'] == 1 && strlen($_REQUEST['firescope_grid_filterText']) > 0) {
		$sql.=" AND fldfirstnameinitial LIKE '%".$_REQUEST['firescope_grid_filterText']."%'";
	}
	else if ($_REQUEST['firescope_grid_filterCol'] == 2 && strlen($_REQUEST['firescope_grid_filterText']) > 0) {
		$sql.=" AND fldrank LIKE '%".$_REQUEST['firescope_grid_filterText']."%'";
	}
	else if ($_REQUEST['firescope_grid_filterCol'] == 3 && strlen($_REQUEST['firescope_grid_filterText']) > 0) {
		$sql.=" AND fldservice LIKE '%".$_REQUEST['firescope_grid_filterText']."%'";
	}
	else if ($_REQUEST['firescope_grid_filterCol'] == 4 && strlen($_REQUEST['firescope_grid_filterText']) > 0) {
		$sql.=" AND fldunit LIKE '%".$_REQUEST['firescope_grid_filterText']."%'";
	}		
	else if ($_REQUEST['firescope_grid_filterCol'] == 5 && strlen($_REQUEST['firescope_grid_filterText']) > 0) {
		$sql.=" AND fldcountry LIKE '%".$_REQUEST['firescope_grid_filterText']."%'";
	}		
	else if ($_REQUEST['firescope_grid_filterCol'] == 6 && strlen($_REQUEST['firescope_grid_filterText']) > 0) {
		$sql.=" AND fldcemetery LIKE '%".$_REQUEST['firescope_grid_filterText']."%'";
	}		


	if ($_REQUEST['firescope_grid_sortCol'] == 0) {
		$sql.=" ORDER BY fldsurname ".$_REQUEST['firescope_grid_sortOrder'];
	}		
	else if ($_REQUEST['firescope_grid_sortCol'] == 1) {
		$sql.=" ORDER BY fldfirstnameinitial ".$_REQUEST['firescope_grid_sortOrder'];
	}
	else if ($_REQUEST['firescope_grid_sortCol'] == 2) {
		$sql.=" ORDER BY fldrank ".$_REQUEST['firescope_grid_sortOrder'];
	}
	else if ($_REQUEST['firescope_grid_sortCol'] == 3) {
		$sql.=" ORDER BY fldservice ".$_REQUEST['firescope_grid_sortOrder'];
	}
	else if ($_REQUEST['firescope_grid_sortCol'] == 4) {
		$sql.=" ORDER BY fldunit ".$_REQUEST['firescope_grid_sortOrder'];
	}
	else if ($_REQUEST['firescope_grid_sortCol'] == 5) {
		$sql.=" ORDER BY fldcountry ".$_REQUEST['firescope_grid_sortOrder'];
	}

	else if ($_REQUEST['firescope_grid_sortCol'] == 6) {
		$sql.=" ORDER BY fldcemetery ".$_REQUEST['firescope_grid_sortOrder'];
	}



	$qry = $dbh->query($sql);

	$rows = $qry->fetchAll();

	$total = count($rows);

	$offset = ($_REQUEST['firescope_grid_page'] - 1) * $_REQUEST['firescope_grid_rows'];
	$rows = array_slice($rows, $offset, $_REQUEST['firescope_grid_rows']);
	// or use mysql_data_seek() 
	// or add a `LIMIT $offset, $_REQUEST['firescope_grid_rows']` to your sql

	$output = '

	<table align=center>
	<tr>
	<th>Surname</th>
	<th>Given Name/Initial</th>
	<th>Rank</th>
	<th>Service</th
	><th>Unit</th>
	<th>Commemorated in</th>
	<th>Commemorated in</th>
	<th> </th>
	</tr>
	';

	while($rows = mysql_fetch_array($result)){
		$output .= '<tr>
		<td>'.$row['fldsurname'].'</td>
		<td>'.$row['fldfirstnameinitial'].'</td>			
		<td>'.$row['fldrank'].'</td>
		<td>'.$row['fldservice'].'</td>		
		<td>'.$row['fldunit'].'</td>
		<td>'.$row['fldcountry'].'</td>		
		<td>'.$row['fldcemetery'].'</td>						
		<td><a href=details.php?id='.$row['ID'].'>Details</td>

		';
	}
	$output .= '
	</table>';

	ob_clean();
	echo '<span id="firescope_grid_example_total" style="display:none">'.$total.'</span>';
	echo '<span>'.$output.'</span>';
	exit();

} catch(PDOException $e) {
	echo $e->getMessage();
}	

}
	echo $sql;
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.