<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_notes = 10;
$pageNum_notes = 0;
if (isset($_GET['pageNum_notes'])) {
$pageNum_notes = $_GET['pageNum_notes'];
}
$startRow_notes = $pageNum_notes * $maxRows_notes;
mysql_select_db($database_site, $site);
$query_notes = "SELECT categories.name, notes.added, notes.title, notes.content, notes.importance, notes.id FROM notes, categories WHERE notes.catid=categories.id ORDER BY notes.id DESC";
$query_limit_notes = sprintf("%s LIMIT %d, %d", $query_notes, $startRow_notes, $maxRows_notes);
$notes = mysql_query($query_limit_notes, $site) or die(mysql_error());
$row_notes = mysql_fetch_assoc($notes);
if (isset($_GET['totalRows_notes'])) {
$totalRows_notes = $_GET['totalRows_notes'];
} else {
$all_notes = mysql_query($query_notes);
$totalRows_notes = mysql_num_rows($all_notes);
}
$totalPages_notes = ceil($totalRows_notes/$maxRows_notes)-1;
mysql_select_db($database_site, $site);
$query_categories = "SELECT name FROM categories";
$categories = mysql_query($query_categories, $site) or die(mysql_error());
$row_categories = mysql_fetch_assoc($categories);
$totalRows_categories = mysql_num_rows($categories);
$queryString_notes = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_notes") == false &&
stristr($param, "totalRows_notes") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_notes = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_notes = sprintf("&totalRows_notes=%d%s", $totalRows_notes, $queryString_notes);
?>
делаю вот такой запрос
<?php echo $row_categories['name']; ?>
но выводящиеся данные не соответствуют условию notes.catid=categories.id
Подскажите в чём ошибка ?