Ver Mensaje Individual
  #11 (permalink)  
Antiguo 25/07/2008, 04:00
tonimito
 
Fecha de Ingreso: diciembre-2003
Mensajes: 157
Antigüedad: 20 años, 4 meses
Puntos: 1
Respuesta: Saltar Campo si el valor es NULL

Hola Marvin,

Si, lo pasteo igual y me ocurre lo comentado... Os pongo todo el código, no me deja poner más de 10000 caracteres, así que lo desgloso en 3 post.

Primera parte:

Código:
<?php require_once('Connections/IPM.php'); ?>
<?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_newsbox = 3;
$pageNum_newsbox = 0;
if (isset($_GET['pageNum_newsbox'])) {
  $pageNum_newsbox = $_GET['pageNum_newsbox'];
}
$startRow_newsbox = $pageNum_newsbox * $maxRows_newsbox;

mysql_select_db($database_IPM, $IPM);
$query_newsbox = "SELECT * FROM news ORDER BY Id_News DESC";
$query_limit_newsbox = sprintf("%s LIMIT %d, %d", $query_newsbox, $startRow_newsbox, $maxRows_newsbox);
$newsbox = mysql_query($query_limit_newsbox, $IPM) or die(mysql_error());
$row_newsbox = mysql_fetch_assoc($newsbox);

if (isset($_GET['totalRows_newsbox'])) {
  $totalRows_newsbox = $_GET['totalRows_newsbox'];
} else {
  $all_newsbox = mysql_query($query_newsbox);
  $totalRows_newsbox = mysql_num_rows($all_newsbox);
}
$totalPages_newsbox = ceil($totalRows_newsbox/$maxRows_newsbox)-1;

$maxRows_newshome = 3;
$pageNum_newshome = 0;
if (isset($_GET['pageNum_newshome'])) {
  $pageNum_newshome = $_GET['pageNum_newshome'];
}
$startRow_newshome = $pageNum_newshome * $maxRows_newshome;

mysql_select_db($database_IPM, $IPM);
$query_newshome = "SELECT Id_News, Texto_Cast, Texto_Catala, Texto_English, `Home _Foto`, Home_Titular_Cast, Home_Titular_Catala, Home_Titular_English FROM news ORDER BY Id_News DESC";
$query_limit_newshome = sprintf("%s LIMIT %d, %d", $query_newshome, $startRow_newshome, $maxRows_newshome);
$newshome = mysql_query($query_limit_newshome, $IPM) or die(mysql_error());
$row_newshome = mysql_fetch_assoc($newshome);

if (isset($_GET['totalRows_newshome'])) {
  $totalRows_newshome = $_GET['totalRows_newshome'];
} else {
  $all_newshome = mysql_query($query_newshome);
  $totalRows_newshome = mysql_num_rows($all_newshome);
}
$totalPages_newshome = ceil($totalRows_newshome/$maxRows_newshome)-1;

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