Ver Mensaje Individual
  #6 (permalink)  
Antiguo 05/04/2009, 08:16
claute
 
Fecha de Ingreso: noviembre-2003
Mensajes: 20
Antigüedad: 20 años, 5 meses
Puntos: 3
Respuesta: Consulta de Base de datos MYSQL y PHP

aca les pongo todo el código porque no me funciona.


Código:
<?php require_once('Connections/lrn.php'); ?>
<?php
$mysql_date = date("Y-m-d"); 
$mysql_time = date("H:i:s");

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

$maxRows_RS_noticias_1 = 4;
$pageNum_RS_noticias_1 = 0;
if (isset($_GET['pageNum_RS_noticias_1'])) {
  $pageNum_RS_noticias_1 = $_GET['pageNum_RS_noticias_1'];
}
$startRow_RS_noticias_1 = $pageNum_RS_noticias_1 * $maxRows_RS_noticias_1;

$colname_RS_noticias_1 = "-1";
if (isset($_GET['fecha'])) {
  $colname_RS_noticias_1 = $_GET['fecha'];
}
mysql_select_db($database_lrn, $lrn);
$query_RS_noticias_1 = sprintf("SELECT noticias.*,multimedia.* FROM noticias INNER JOIN multimedia ON noticias.id_noticia = multimedia.id_noticia WHERE noticias.fecha <= '$mysql_date' AND noticias.tipo = 'PRINCIPAL' AND noticias.Seccion <> 'Deportes' AND noticias.seccion <> 'Tecnologia' ORDER BY noticias.fecha DESC, noticias.prioridad DESC, noticias.hora DESC ", GetSQLValueString($colname_RS_noticias_1, "date"));
$query_limit_RS_noticias_1 = sprintf("%s LIMIT %d, %d", $query_RS_noticias_1, $startRow_RS_noticias_1, $maxRows_RS_noticias_1);
$RS_noticias_1 = mysql_query($query_limit_RS_noticias_1, $lrn) or die(mysql_error());
$row_RS_noticias_1 = mysql_fetch_assoc($RS_noticias_1);

if (isset($_GET['totalRows_RS_noticias_1'])) {
  $totalRows_RS_noticias_1 = $_GET['totalRows_RS_noticias_1'];
} else {
  $all_RS_noticias_1 = mysql_query($query_RS_noticias_1);
  $totalRows_RS_noticias_1 = mysql_num_rows($all_RS_noticias_1);
}
$totalPages_RS_noticias_1 = ceil($totalRows_RS_noticias_1/$maxRows_RS_noticias_1)-1;
?><!-- NOTICIA NUMERO 1 -->
<link href="../estilos/noticias.css" rel="stylesheet" type="text/css" />

<table width="425" border="0">
  <?php do { ?>
    <tr>
      <td><table border="0" cellpadding="0" cellspacing="0" width="425">
        <tbody>
          <tr>
            <td width="25" valign="top"><img src="img/check2.gif" align="top"></td>
            <td width="417" class="tahoma t11 c10 tdnone"><span class="fecha_home"><?php echo makeDateTime($row_RS_noticias_1['fecha'], 'd-m-y'); ?> - <strong><?php echo $row_RS_noticias_1['seccion']; ?></strong></span><strong><br />
                <span class="copete_home"><?php echo $row_RS_noticias_1['copete']; ?></span></strong></td>
          </tr>
          <tr>
            <td colspan="2" height="4"></td>
            </tr>
          <tr>
            <td colspan="2" class="titulo"><a href="noticia.php?id_noticia=<?php echo $row_RS_noticias_1['id_noticia']; ?>" class="titulo"><?php echo $row_RS_noticias_1['titulo']; ?></a></td>
          </tr>
          <tr>
            <td colspan="2" height="4"></td>
            </tr>
          <tr>
            <td colspan="2"><?php if ($row_RS_noticias_1['foto1'] <> "") { // Show if recordset not empty ?>
                  <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666">
                    <tr>
                      <td><img src="fotos/<?php echo $row_RS_noticias_1['foto1']; ?>" width="423" /></td>
                    </tr>
                                        </table>
                  <?php } // Show if recordset not empty ?>                </td>
          </tr>
          <tr>
            <td colspan="2" height="10"></td>
            </tr>
          <tr>
            <td colspan="2" class="bajada"><?php echo nl2br($row_RS_noticias_1['bajada']); ?></td>
          </tr>
          <tr>
            <td colspan="2" height="10"></td>
            </tr>
          <tr>
            <td colspan="2" background="img/fondo_raya.gif" height="1"></td>
            </tr>
          <tr>
            <td colspan="2" height="10"></td>
            </tr>
        </tbody>
      </table></td>
    </tr>
    <?php } while ($row_RS_noticias_1 = mysql_fetch_assoc($RS_noticias_1)); ?>
</table>
<!-- FIN NOTICIA NUMERO 1 -->
<?php
mysql_free_result($RS_noticias_1);
?>