I have the following code for a page I need to include in my MODX CMS. I find it difficult reconcilling it in my MODX how can I do it. Please help
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
echo "<table width=’100%’ border=’1’><tr> <td>
<form id=’form1’ name=’form1’ method=’post’ action=’testApplication.php’>
<table width=’100%’ border=’0’>
<tr>
<td>Search Profile </td>
<td><input name=’q’ type=’text’ id=’q’ /></td>
<td><select name=’s’ >
<option value=’first_name’ selected=’selected’>First Name</option>
<option value=’Surname’>Surname</option>
<option value=’Designation’>Designation</option>
<option value=’Office_extension ’>Extension</option>
<option value=’Official_email’>Email</option>
</select></td>
<td><input type=’submit’ name=’Submit’ value=’Search’ /></td>
</tr>
</table>
</form>
</td>
</tr><tr><td>";
$var = $_POST[’q’] ;
$var2 = $_POST[’s’] ;
$trimmed = trim($var); //trim whitespace from the stored variable
// check for an empty string and display a message.
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit();
}
// Connects to your Database
mysql_connect("localhost", "root", "Sysoper234") or die(mysql_error());
mysql_select_db("nnradb") or die(mysql_error());
$variable="’".$trimmed."%’";
$sql = "select * from tb_staff_record where ".$var2." like ".$variable;
$data = mysql_query($sql) or die(mysql_error());
$rows = mysql_num_rows($data);
if ($rows==0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
exit();
}
else
{
Print "<table width=’100%’ border=’0’>
<tr>
<td >S/No </td>
<td >File No </td>
<td >Surname</td>
<td >First Name </td>
<td >Middle Name </td>
<td >Designation</td>
<td >Email</td>
</tr>";
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
//Here we count the number of results
//Edit $data to be your query
$data = mysql_query($sql) or die(mysql_error());
$rows = mysql_num_rows($data);
//This is the number of results displayed per page
$page_rows = 30;
//This tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure the page number isn’t below one, or more than our maximum pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
$order="ORDER BY ".$var2." ASC ";
//This sets range that we will display in our query
$max = ’limit ’ .($pagenum - 1) * $page_rows .’,’ .$page_rows;
//This is your query again, the same one... the only difference is we add $max into it
$data_p = mysql_query($sql.$order.$max) or die(mysql_error());
//This is where you display your query results
$count = 1 + $s ;
while($info = mysql_fetch_array( $data_p ))
{
Print "<tr>";
Print "<td >".$count."</td>";
Print "<td>".$info[’File_no’]."</td>";
Print "<td>".$info[’Surname’]."</td>";
Print "<td>".$info[’First_name’]."</td>";
Print "<td>".$info[’Middle_name’]."</td>";
Print "<td>".$info[’Designation’]."</td>";
Print "<td>".$info[’Official_email’]."</td>";
Print "</tr>";
//Print $info[’Surname’];
$count++;
}
Print "<tr><td colspan=’7’>";
// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- <p>";
// First we check if we are on page one. If we are then we don’t need a link to the previous page or the first page so we do nothing. If we aren’t then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{
}
else
{
echo " <a href=’{$_SERVER[’testApplication.php’]}?pagenum=1’> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href=’{$_SERVER[’testApplication.php’]}?pagenum=$previous’> <-Previous</a> ";
}
//echo $PHP_SELF;
//just a spacer
//echo " ---- ";
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href=’{$_SERVER[’query.php’]}?pagenum=$next’>Next -></a> ";
echo " ";
echo " <a href=’{$_SERVER[’query.php’]}?pagenum=$last’>Last ->></a> ";
}
echo "</tr></td></table>";
echo "</table>";
}
Print "</td></tr></table>";
?>
</body>
</html>