Foros del Web » Programando para Internet » PHP »

PHP OO Problema pagina directorio mostrar mensaje de error

Estas en el tema de Problema pagina directorio mostrar mensaje de error en el foro de PHP en Foros del Web. Hola gente de foros del web, mi problema es el suguiente: tengo una pagina para un centro comercial, en la pagina donde se encuentra el ...
  #1 (permalink)  
Antiguo 07/01/2012, 23:41
 
Fecha de Ingreso: abril-2011
Mensajes: 15
Antigüedad: 13 años
Puntos: 0
Problema pagina directorio mostrar mensaje de error

Hola gente de foros del web, mi problema es el suguiente: tengo una pagina para un centro comercial, en la pagina donde se encuentra el directorio de las tiendas he puesto todas las categorias que son llamadas desde un juego de registros llamado rsCategorias al cual no le paso ningun filtro, en el mismo tengo un juego de registros llamado rsLocal al cual le pongo que lo filtre por la categoria, todo bien hasta alli, todos los registros de las categorias me las pone a un lado de la pagina con una region repetida (de el juego de registros rsCategorias) que a cada una le puse que valla a una pagina de detalle la cual es la misma pagina, y me llama los resultados en una region repetida (de el juego de registros rsLocal) todo perfecto hasta aqui, ahora bien lo que quiero es que si se le da click a una de las categorias me muestre el mensaje de: no hay registros de esta categoria, la verdad que he buscado como loco y no consigo que me funcione, una de las formas que utilice fue con este codigo:

Código PHP:
<?php 
     
if(mysql_num_rows($rsLocal) == 0)
         { 
          echo 
'<hr />
     <h1 class="errorpage">NO HAY REGISTROS<br />
                           DE ESTA CATEGORIA
         <hr />'

          } 
          
?>
el proble es que cuando llamo la pagina directorio desde el index cuando abre me muestra de una vez el error de que no existen registros de esta categoria.

lo que quiero es que cuando abra la pagina me muestre: seleccione la categoria y si le doy a alguno de los link desaparezca "seleccione la categoria" y que, si no hay registros me muestre el mensaje de error.

si no me explique bien me lo dicen por favor!
  #2 (permalink)  
Antiguo 07/01/2012, 23:43
 
Fecha de Ingreso: abril-2011
Mensajes: 15
Antigüedad: 13 años
Puntos: 0
Respuesta: Problema pagina directorio mostrar mensaje de error

aqui voy a poner el codigo php (el codigo lo genera el dreamweaver automaticamente):

Código PHP:
Ver original
  1. <?php require_once('Connections/cnx.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. mysql_select_db($database_cnx, $cnx);
  35. $query_rsCategorias = "SELECT * FROM categorias";
  36. $rsCategorias = mysql_query($query_rsCategorias, $cnx) or die(mysql_error());
  37. $row_rsCategorias = mysql_fetch_assoc($rsCategorias);
  38. $totalRows_rsCategorias = mysql_num_rows($rsCategorias);
  39.  
  40. $colname_rsLocal = "-1";
  41. if (isset($_GET['categoria'])) {
  42.   $colname_rsLocal = $_GET['categoria'];
  43. }
  44. mysql_select_db($database_cnx, $cnx);
  45. $query_rsLocal = sprintf("SELECT * FROM `local` WHERE categoria = %s", GetSQLValueString($colname_rsLocal, "text"));
  46. $rsLocal = mysql_query($query_rsLocal, $cnx) or die(mysql_error());
  47. $row_rsLocal = mysql_fetch_assoc($rsLocal);
  48. $totalRows_rsLocal = mysql_num_rows($rsLocal);
  49.  
  50. $MM_paramName = "";
  51.  
  52. // *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
  53. // create the list of parameters which should not be maintained
  54. $MM_removeList = "&index=";
  55. if ($MM_paramName != "") $MM_removeList .= "&".strtolower($MM_paramName)."=";
  56. $MM_keepURL="";
  57. $MM_keepForm="";
  58. $MM_keepBoth="";
  59. $MM_keepNone="";
  60. // add the URL parameters to the MM_keepURL string
  61. reset ($_GET);
  62. while (list ($key, $val) = each ($_GET)) {
  63.     $nextItem = "&".strtolower($key)."=";
  64.     if (!stristr($MM_removeList, $nextItem)) {
  65.         $MM_keepURL .= "&".$key."=".urlencode($val);
  66.     }
  67. }
  68. // add the Form parameters to the MM_keepURL string
  69. if(isset($_POST)){
  70.     reset ($_POST);
  71.     while (list ($key, $val) = each ($_POST)) {
  72.         $nextItem = "&".strtolower($key)."=";
  73.         if (!stristr($MM_removeList, $nextItem)) {
  74.             $MM_keepForm .= "&".$key."=".urlencode($val);
  75.         }
  76.     }
  77. }
  78. // create the Form + URL string and remove the intial '&' from each of the strings
  79. $MM_keepBoth = $MM_keepURL."&".$MM_keepForm;
  80. if (strlen($MM_keepBoth) > 0) $MM_keepBoth = substr($MM_keepBoth, 1);
  81. if (strlen($MM_keepURL) > 0)  $MM_keepURL = substr($MM_keepURL, 1);
  82. if (strlen($MM_keepForm) > 0) $MM_keepForm = substr($MM_keepForm, 1);
  83. ?>
  #3 (permalink)  
Antiguo 07/01/2012, 23:44
 
Fecha de Ingreso: abril-2011
Mensajes: 15
Antigüedad: 13 años
Puntos: 0
Respuesta: Problema pagina directorio mostrar mensaje de error

aqui pongo el codigo html:

Código HTML:
Ver original
  1. <meta charset="utf8_general_ci"></head>
  2.     <div id="wrapper">
  3.    
  4.         <div id="wrapper-top">
  5.                 <div id="top">
  6.                     <div id="top-left"><a href="./index.php"><img src="http://localhost/vasconia/images/logo.png" alt="Centro Comercial Vasconia" /></a></div><!-- #top-left -->
  7.                     <div id="top-right">
  8.                         <div id="nav">
  9.                             <ul id="topnav">
  10.                 <li><a href="http://localhost/vasconia/index.php" >Inicio</a></li>
  11.                 <li><a href="#">Nosotros</a></li>
  12.                 <li class="active"><a href="http://localhost/vasconia/directorio.php">Directorio</a></li>
  13.                 <li><a href="#">Promociones</a></li>
  14.                 <li><a href="#">Galeria</a></li>
  15.                 <li><a href="http://localhost/vasconia/contact.html">Contactenos</a></li>
  16.                             </ul>
  17.                             <!-- #topnav -->
  18.                         </div><!-- #nav -->
  19.                     </div><!-- #top-right -->
  20.                 </div><!-- #top -->
  21.         </div><!-- #wrapper-top -->
  22.        
  23.         <div id="wrapper-after-top">
  24.                 <div id="breadcrumb">
  25.                 <a href="index.php">Inicio</a> / <a href="directorio.php">Directorio</a>
  26.                 </div><!-- #breadcrumb -->
  27.         </div><!-- #wrapper-after-top -->
  28.        
  29.         <div id="wrapper-header-inner">
  30.                 <div id="header-inner">
  31.                 <form action="" method="post"  id="searchtop">
  32.                     <div>
  33.                     <span class="bg-search"><input type="text"  class="inputsearch" value="Buscar..." onblur="if (this.value == ''){this.value = 'Buscar...'; }" onfocus="if (this.value == 'Buscar...') {this.value = ''; }"/></span>
  34.                     </div>
  35.                 </form>
  36.                 <h1 class="pagetitle">Directorio</h1>
  37.                 </div><!-- #header-inner -->
  38.         </div><!-- #wrapper-header-inner -->
  39.        
  40.         <div id="wrapper-content">
  41.                 <div id="content">
  42.                     <div id="main">
  43.                         <div id="sidebar">
  44.                              <h2 class="widget-title">Categorias</h2>
  45.                           <div class="toggle_container">
  46.                              <div class="block">
  47.                            
  48.                                
  49.                                <?php do { ?>
  50.                                <li><a href="directorio.php?<?php echo $MM_keepNone.(($MM_keepNone!="")?"&":"")."categoria=".urlencode($row_rsCategorias['categoria']) ?>"><?php echo $row_rsCategorias['categoria']; ?></a></li>
  51.                                  <?php } while ($row_rsCategorias = mysql_fetch_assoc($rsCategorias)); ?>
  52.                             </div>
  53.                           </div>
  54.                         </div><!-- #sidebar -->
  55.                         <div id="maincontent_result">
  56.                         <?php
  57.                         if(mysql_num_rows($rsLocal) == 0)
  58.                        {
  59.                    echo '<hr />
  60.                     <h1 class="errorpage">NO HAY REGISTROS<br />
  61.                     DE ESTA CATEGORIA
  62.                     </h1>
  63.                     <hr />';
  64.                         }
  65.                     ?>
  66.                           <?php do { ?>
  67.                               <?php if ($totalRows_rsLocal > 0) { // Show if recordset not empty ?>
  68.   <div class="one_third_local">
  69.     <?php echo $row_rsLocal['nombre_completo']; ?>
  70.     <img src="images/logo/<?php echo $row_rsLocal['logo']; ?>" alt="" width="180" height="50" /><br />
  71.     Nivel: <?php echo $row_rsLocal['nivel']; ?><br />
  72.     Local: <?php echo $row_rsLocal['local']; ?><br />
  73.     Tel&eacute;fono: <?php echo $row_rsLocal['telefono_1']; ?> / <?php echo $row_rsLocal['telefono_2']; ?><br />
  74.     Email: <?php echo $row_rsLocal['email']; ?></div>
  75.   <?php } // Show if recordset not empty ?>
  76. <?php } while ($row_rsLocal = mysql_fetch_assoc($rsLocal)); ?>
  77.                            
  78.                             <div class="clear"></div>
  79.                       </div><!-- #maincontent -->
  80.                         <div class="clear"></div>
  81.                     </div><!-- #main -->
  82.                 </div><!-- #content -->
  83.         </div><!-- #wrapper-content -->
  84.        
  85.         <div id="wrapper-bottom">
  86.             <div id="tweets">
  87.                 <div id="twitter"></div>
  88.             </div><!-- #tweets -->
  89.         </div><!-- #wrapper-bottom --><!-- #wrapper-footer -->
  90.        
  91.         <div id="wrapper-footer-text">
  92.             <div id="footer-text">
  93.                 <div id="footnav">
  94.                 <ul>
  95.                     <li><a href="http://localhost/vasconia/index.php">Inicio</a></li>
  96.                     <li><a href="#">Nosotros</a></li>
  97.                     <li><a href="#">Directorio</a></li>
  98.                     <li><a href="#">Promociones</a></li>
  99.                     <li> <a href="#">Galeria</a></li>
  100.                     <li><a href="http://localhost/vasconia/contact.html">Contactenos</a></li>
  101.                 </ul>
  102.                 </div><!-- #footnav -->
  103.                 <div id="copyright">Copyright &copy;2012 C.C. Vasconia. Todos los derechos reservados - Powered by <a href="http://www.teksyte.com" target="_blank">Teksyte</a></div><!-- #copyright -->
  104.             </div><!-- #footer-text -->
  105.         </div><!-- #wrapper-footer-text -->
  106.        
  107.     </div><!-- #wrapper -->
  108.    
  109.     <script type="text/javascript"> Cufon.now(); </script> <!-- to fix cufon problems in IE browser -->
  110.     <script type="text/javascript">jQuery('#noscript').remove();</script><!-- if javascript disable -->
  111. </body>

Etiquetas: directorio, mensaje, registro, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:35.