if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_staffer1, $staffer1);
// Логика
$query_Recordset1 = "SELECT * FROM vacancy";
if (count($Wheres))
{
$query_Recordset1 .= " WHERE ".join( ' AND ', $Wheres );
$query_Recordset1 .= " ORDER BY dolghn ASC, date DESC";
}
//
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $staffer1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php echo $query_Recordset1; ?>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td>id</td>
<td>num</td>
<td>date</td>
<td>region</td>
<td>zarp</td>
<td>sex</td>
<td>age</td>
<td>educ</td>
<td>opyt</td>
<td>opyt1</td>
<td>opyt2</td>
<td>dolghn</td>
<td>graphik</td>
<td>email</td>
<td>tel</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['id']; ?></td>
<td><?php echo $row_Recordset1['num']; ?></td>
<td><?php echo $row_Recordset1['date']; ?></td>
<td><?php echo $row_Recordset1['region']; ?></td>
<td><?php echo $row_Recordset1['zarp']; ?></td>
<td><?php echo $row_Recordset1['sex']; ?></td>
<td><?php echo $row_Recordset1['age']; ?></td>
<td><?php echo $row_Recordset1['educ']; ?></td>
<td><?php echo $row_Recordset1['opyt']; ?></td>
<td><?php echo $row_Recordset1['opyt1']; ?></td>
<td><?php echo $row_Recordset1['opyt2']; ?></td>
<td><?php echo $row_Recordset1['dolghn']; ?></td>
<td><?php echo $row_Recordset1['graphik']; ?></td>
<td><?php echo $row_Recordset1['email']; ?></td>
<td><?php echo $row_Recordset1['tel']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>">First</a> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">Previous</a> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">Next</a> <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>">Last</a> <?php echo ($startRow_Recordset1 + 1) ?> <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> <?php echo $totalRows_Recordset1 ?></p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
----------------------------------------------------
Don't understand what is wrong. The first page works, next and last giving error. Where is my mistake? Thank you!