Tema: dw+php+mysql
Ver Mensaje Individual
  #7 (permalink)  
Antiguo 09/07/2007, 15:58
seres
 
Fecha de Ingreso: junio-2007
Mensajes: 10
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: dw+php+mysql

este es el script de busqueda......
<?php

function buildNavigation($pageNum_Recordset1,$totalPages_Re cordset1,$prev_Recordset1,$next_Recordset1,$separa tor=" | ",$max_links=10, $show_page=true)
{
GLOBAL $maxRows_rssearch,$totalRows_rssearch;
$pagesArray = ""; $firstArray = ""; $lastArray = "";
if($max_links<2)$max_links=2;
if($pageNum_Recordset1<=$totalPages_Recordset1 && $pageNum_Recordset1>=0)
{
if ($pageNum_Recordset1 > ceil($max_links/2))
{
$fgp = $pageNum_Recordset1 - ceil($max_links/2) > 0 ? $pageNum_Recordset1 - ceil($max_links/2) : 1;
$egp = $pageNum_Recordset1 + ceil($max_links/2);
if ($egp >= $totalPages_Recordset1)
{
$egp = $totalPages_Recordset1+1;
$fgp = $totalPages_Recordset1 - ($max_links-1) > 0 ? $totalPages_Recordset1 - ($max_links-1) : 1;
}
}
else {
$fgp = 0;
$egp = $totalPages_Recordset1 >= $max_links ? $max_links : $totalPages_Recordset1+1;
}
if($totalPages_Recordset1 >= 1) {

$_get_vars = '';
if(!empty($_GET) || !empty($HTTP_GET_VARS)){
$_GET = empty($_GET) ? $HTTP_GET_VARS : $_GET;
foreach ($_GET as $_get_name => $_get_value) {
if ($_get_name != "pageNum_rssearch") {
$_get_vars .= "&$_get_name=$_get_value";
}
}
}
$successivo = $pageNum_Recordset1+1;
$precedente = $pageNum_Recordset1-1;
$firstArray = ($pageNum_Recordset1 > 0) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_rssearch=$precedente$_get_vars\">$prev_Re cordset1</a>" : "$prev_Recordset1";
# ----------------------
# page numbers
# ----------------------
for($a = $fgp+1; $a <= $egp; $a++){
$theNext = $a-1;
if($show_page)
{
$textLink = $a;
} else {
$min_l = (($a-1)*$maxRows_rssearch) + 1;
$max_l = ($a*$maxRows_rssearch >= $totalRows_rssearch) ? $totalRows_rssearch : ($a*$maxRows_rssearch);
$textLink = "$min_l - $max_l";
}
$_ss_k = floor($theNext/26);
if ($theNext != $pageNum_Recordset1)
{
$pagesArray .= "<a href=\"$_SERVER[PHP_SELF]?pageNum_rssearch=$theNext$_get_vars\">";
$pagesArray .= "$textLink</a>" . ($theNext < $egp-1 ? $separator : "");
} else {
$pagesArray .= "$textLink" . ($theNext < $egp-1 ? $separator : "");
}
}
$theNext = $pageNum_Recordset1+1;
$offset_end = $totalPages_Recordset1;
$lastArray = ($pageNum_Recordset1 < $totalPages_Recordset1) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_rssearch=$successivo$_get_vars\">$next_Re cordset1</a>" : "$next_Recordset1";
}
}
return array($firstArray,$pagesArray,$lastArray);
}
?><?php require_once('Connections/tp2000.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "http://www.camarapuno.org";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "wrong.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_rssearch = 20;
$pageNum_rssearch = 0;
if (isset($_GET['pageNum_rssearch'])) {
$pageNum_rssearch = $_GET['pageNum_rssearch'];
}
$startRow_rssearch = $pageNum_rssearch * $maxRows_rssearch;

$colname_rssearch = "-1";
if (isset($_GET['aceptante'])) {
$colname_rssearch = (get_magic_quotes_gpc()) ? $_GET['aceptante'] : addslashes($_GET['aceptante']);
}
mysql_select_db($database_tp2000, $tp2000);
$query_rssearch = sprintf("SELECT * FROM tp2000 WHERE aceptante = '%s'", $colname_rssearch);
$query_limit_rssearch = sprintf("%s LIMIT %d, %d", $query_rssearch, $startRow_rssearch, $maxRows_rssearch);
$rssearch = mysql_query($query_limit_rssearch, $tp2000) or die(mysql_error());
$row_rssearch = mysql_fetch_assoc($rssearch);

if (isset($_GET['totalRows_rssearch'])) {
$totalRows_rssearch = $_GET['totalRows_rssearch'];
} else {
$all_rssearch = mysql_query($query_rssearch);
$totalRows_rssearch = mysql_num_rows($all_rssearch);
}
$totalPages_rssearch = ceil($totalRows_rssearch/$maxRows_rssearch)-1;

$queryString_rssearch = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rssearch") == false &&
stristr($param, "totalRows_rssearch") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rssearch = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rssearch = sprintf("&totalRows_rssearch=%d%s", $totalRows_rssearch, $queryString_rssearch);

$maxRows_rssearch = 5;
$pageNum_rssearch = 0;
if (isset($_GET['pageNum_rssearch'])) {
$pageNum_rssearch = $_GET['pageNum_rssearch'];
}
$startRow_rssearch = $pageNum_rssearch * $maxRows_rssearch;

$colname_rssearch = "-1";
if (isset($_GET['nombre'])) {
$colname_rssearch = (get_magic_quotes_gpc()) ? $_GET['nombre'] : addslashes($_GET['nombre']);
}
mysql_select_db($database_tp2000, $tp2000);
//----------------------este es el q hace el like-----------

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;
}
}
continua------