Jump to content


Wellingtons.com.br

Member Since 21/01/2012
Offline Last Active 21/01/2012, 14:29
-----

Topics I've Started

Problemas Com A Lista Depois De Gerar O Recordset

21/01/2012, 12:37

Amigos,

Estou fazendo um site de notícias. Assim, criei bancos do mysql e fiz os gerenciadores e formulário de postaem de notícias no DW CS4 com a ferramenta develope toolbox. Deu super certo. No entanto, quando fui criar página para listar as notícias com parâmetros tive problemas. Gostaria que fossem listadas apenas as notícias de uma seção. Assim, de forma que tivesse 4 listas separadas por temas, no caso: notícias, trânsito, serviços e classificados. Inseri no bd um campo que tivesse essas 4 seções. Até aí tudo bem. Quando fiz o recordset inclui no parâmetro uma seção, o teste validou e listou para mim as notícias de uma determinada seção, mas quando incluí os campos na página de exibição {CRASH}, não aprece nenhum registro (mesmo o teste dando a lista certa. Quando eu tiro o parâmetro {PUMBA} aparecem todas as notícias cadastradas de todas as seções.

Vai o código com o parâmetro, mais abaixo o código sem parâmetro: (destaque que o parâmetro é notícias:


$maxRows_rsNot_index = 5;
$pageNum_rsNot_index = 0;
if (isset($_GET['pageNum_rsNot_index'])) {
$pageNum_rsNot_index = $_GET['pageNum_rsNot_index'];
}
$startRow_rsNot_index = $pageNum_rsNot_index * $maxRows_rsNot_index;

$colname_rsNot_index = "-1";
if (isset($_GET['noticia'])) {
$colname_rsNot_index = $_GET['noticia'];
}
mysql_select_db($database_conEai, $conEai);
$query_rsNot_index = sprintf("SELECT * FROM noticias WHERE not_secao LIKE %s ORDER BY not_id DESC", GetSQLValueString("%" . $colname_rsNot_index . "%", "text"));
$query_limit_rsNot_index = sprintf("%s LIMIT %d, %d", $query_rsNot_index, $startRow_rsNot_index, $maxRows_rsNot_index);
$rsNot_index = mysql_query($query_limit_rsNot_index, $conEai) or die(mysql_error());
$row_rsNot_index = mysql_fetch_assoc($rsNot_index);

if (isset($_GET['totalRows_rsNot_index'])) {
$totalRows_rsNot_index = $_GET['totalRows_rsNot_index'];
} else {
$all_rsNot_index = mysql_query($query_rsNot_index);
$totalRows_rsNot_index = mysql_num_rows($all_rsNot_index);
}
$totalPages_rsNot_index = ceil($totalRows_rsNot_index/$maxRows_rsNot_index)-1;
?>

Esse caso aceita o teste, mas não lista


Nesse código abaixo, sem o parâmetro noticias - a página lista normalmente

<?php require_once('../Connections/conEai.php'); ?>
<?php
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;
}
}

$maxRows_rsNot_index = 5;
$pageNum_rsNot_index = 0;
if (isset($_GET['pageNum_rsNot_index'])) {
$pageNum_rsNot_index = $_GET['pageNum_rsNot_index'];
}
$startRow_rsNot_index = $pageNum_rsNot_index * $maxRows_rsNot_index;

mysql_select_db($database_conEai, $conEai);
$query_rsNot_index = "SELECT * FROM noticias ORDER BY not_id DESC";
$query_limit_rsNot_index = sprintf("%s LIMIT %d, %d", $query_rsNot_index, $startRow_rsNot_index, $maxRows_rsNot_index);
$rsNot_index = mysql_query($query_limit_rsNot_index, $conEai) or die(mysql_error());
$row_rsNot_index = mysql_fetch_assoc($rsNot_index);

if (isset($_GET['totalRows_rsNot_index'])) {
$totalRows_rsNot_index = $_GET['totalRows_rsNot_index'];
} else {
$all_rsNot_index = mysql_query($query_rsNot_index);
$totalRows_rsNot_index = mysql_num_rows($all_rsNot_index);
}
$totalPages_rsNot_index = ceil($totalRows_rsNot_index/$maxRows_rsNot_index)-1;
?>

IPB Skin By Virteq