Foros del Web » Programación para mayores de 30 ;) » Java »

Borrar fila con condicion

Estas en el tema de Borrar fila con condicion en el foro de Java en Foros del Web. Buenos dias, tengo un problema a la hora de mostrar los datos en una pagina desde una base de datos y os escribo por si ...
  #1 (permalink)  
Antiguo 25/07/2014, 02:19
 
Fecha de Ingreso: julio-2014
Mensajes: 53
Antigüedad: 9 años, 9 meses
Puntos: 1
Borrar fila con condicion

Buenos dias, tengo un problema a la hora de mostrar los datos en una pagina desde una base de datos y os escribo por si pudierais hacerme el favor de intentar ayudarme:

Tengo un documento .php en el que hay una tabla con los mismos valores que hay en mi base de datos en phpmyadmin. Hay algunos valores, como por ejemplo "Lengua de traduccion 25" que no son rellenados (a veces no se traduce un documento en 25 lenguas) y salen por defecto como "Ninguna". Lo que no quiero es que en esta pagina me salgan las filas "Lengua de traduccion 20", "Lengua de traduccion 21", etc. si estas tienen el valor de "ninguna". A alguien se le ocurre algun codigo para hacerlo?

Muchas gracias de antemano!
  #2 (permalink)  
Antiguo 25/07/2014, 02:34
 
Fecha de Ingreso: julio-2014
Mensajes: 53
Antigüedad: 9 años, 9 meses
Puntos: 1
Respuesta: Borrar fila con condicion

Os pongo aqui el codigo, he probado con este javascript pero no me funciona:

Código PHP:
Ver original
  1. <?php require_once('../Connections/localhost.php'); ?><?php
  2. if (!function_exists("GetSQLValueString")) {
  3. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  4. {
  5.   if (PHP_VERSION < 6) {
  6.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.   }
  8.  
  9.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10.  
  11.   switch ($theType) {
  12.     case "text":
  13.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14.       break;    
  15.     case "long":
  16.     case "int":
  17.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18.       break;
  19.     case "double":
  20.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  21.       break;
  22.     case "date":
  23.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24.       break;
  25.     case "defined":
  26.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27.       break;
  28.   }
  29.   return $theValue;
  30. }
  31. }
  32.  
  33. $maxRows_DetailRS1 = 10;
  34. $pageNum_DetailRS1 = 0;
  35. if (isset($_GET['pageNum_DetailRS1'])) {
  36.   $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
  37. }
  38. $startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;
  39.  
  40. $colname_DetailRS1 = "-1";
  41. if (isset($_GET['recordID'])) {
  42.   $colname_DetailRS1 = $_GET['recordID'];
  43. }
  44. mysql_select_db($database_localhost, $localhost);
  45. $query_DetailRS1 = sprintf("SELECT * FROM presupuestos WHERE Nombre = %s", GetSQLValueString($colname_DetailRS1, "text"));
  46. $query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
  47. $DetailRS1 = mysql_query($query_limit_DetailRS1, $localhost) or die(mysql_error());
  48. $row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
  49.  
  50. if (isset($_GET['totalRows_DetailRS1'])) {
  51.   $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
  52. } else {
  53.   $all_DetailRS1 = mysql_query($query_DetailRS1);
  54.   $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
  55. }
  56. $totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
  57. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  58. <html xmlns="http://www.w3.org/1999/xhtml">
  59. <head>
  60. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  61. <title>Documento sin título</title>
  62. <style type="text/css">
  63. .titulo {
  64.     border-radius: 8px;
  65.     color: #FFF;
  66.     font-weight: bold;
  67. }
  68. .datos {
  69.     border-radius: 8px;
  70.     color: #FFF;
  71. }
  72. </style>
  73. </head>
  74.  
  75. <body>
  76.  
  77. <table border="0" align="center" cellpadding="10" cellspacing="2">
  78.   <tr>
  79.     <td bgcolor="#0000CC" class="titulo">Nombre</td>
  80.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Nombre']; ?></td>
  81.   </tr>
  82.   <tr>
  83.     <td bgcolor="#0000CC" class="titulo">Fecha</td>
  84.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Fecha']; ?></td>
  85.   </tr>
  86.   <tr>
  87.     <td bgcolor="#0000CC" class="titulo">Numero de Oferta</td>
  88.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Numero de Oferta']; ?></td>
  89.   </tr>
  90.   <tr>
  91.     <td bgcolor="#0000CC" class="titulo">Atencion</td>
  92.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Atencion']; ?></td>
  93.   </tr>
  94.  
  95.   <tr>
  96.     <td bgcolor="#0000CC" class="titulo">Lengua source 1</td>
  97.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua source 1']; ?></td>
  98.   </tr>
  99.   <tr>
  100.     <td bgcolor="#0000CC" class="titulo">Lengua target 3</td>
  101.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 3']; ?></td>
  102.   </tr>
  103.   <tr>
  104.     <td bgcolor="#0000CC" class="titulo">Lengua target 4</td>
  105.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 4']; ?></td>
  106.   </tr>
  107.   <tr>
  108.     <td bgcolor="#0000CC" class="titulo">Lengua target 5</td>
  109.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 5']; ?></td>
  110.   </tr>
  111.   <tr>
  112.     <td bgcolor="#0000CC" class="titulo">Lengua target 6</td>
  113.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 6']; ?></td>
  114.   </tr>
  115.   <tr>
  116.     <td bgcolor="#0000CC" class="titulo">Lengua target 7</td>
  117.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 7']; ?></td>
  118.   </tr>
  119.   <tr>
  120.     <td bgcolor="#0000CC" class="titulo">Lengua target 8</td>
  121.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 8']; ?></td>
  122.   </tr>
  123.   <tr>
  124.     <td bgcolor="#0000CC" class="titulo">Lengua target 9</td>
  125.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 9']; ?></td>
  126.   </tr>
  127.   <tr>
  128.     <td bgcolor="#0000CC" class="titulo">Lengua target 10</td>
  129.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 10']; ?></td>
  130.   </tr>
  131.   <tr>
  132.     <td bgcolor="#0000CC" class="titulo">Lengua target 11</td>
  133.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 11']; ?></td>
  134.   </tr>
  135.   <tr>
  136.     <td bgcolor="#0000CC" class="titulo">Lengua target 12</td>
  137.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 12']; ?></td>
  138.   </tr>
  139.   <tr>
  140.     <td bgcolor="#0000CC" class="titulo">Lengua target 13</td>
  141.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 13']; ?></td>
  142.   </tr>
  143.   <tr>
  144.     <td bgcolor="#0000CC" class="titulo">Lengua target 14</td>
  145.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 14']; ?></td>
  146.   </tr>
  147.   <tr>
  148.     <td bgcolor="#0000CC" class="titulo">Lengua target 15</td>
  149.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 15']; ?></td>
  150.   </tr>
  151.   <tr>
  152.     <td bgcolor="#0000CC" class="titulo">Lengua target 16</td>
  153.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 16']; ?></td>
  154.   </tr>
  155.   <tr>
  156.     <td bgcolor="#0000CC" class="titulo">Lengua target 17</td>
  157.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 17']; ?></td>
  158.   </tr>
  159.   <tr>
  160.     <td bgcolor="#0000CC" class="titulo">Lengua target 18</td>
  161.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 18']; ?></td>
  162.   </tr>
  163.   <tr>
  164.     <td bgcolor="#0000CC" class="titulo">Lengua target 19</td>
  165.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 19']; ?></td>
  166.   </tr>
  167.   <tr>
  168.     <td bgcolor="#0000CC" class="titulo">Lengua target 20</td>
  169.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 20']; ?></td>
  170.   </tr>
  171.   <tr>
  172.     <td bgcolor="#0000CC" class="titulo">Lengua target 21</td>
  173.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 21']; ?></td>
  174.   </tr>
  175.   <tr>
  176.     <td bgcolor="#0000CC" class="titulo">Lengua target 22</td>
  177.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 22']; ?></td>
  178.   </tr>
  179.   <tr>
  180.     <td bgcolor="#0000CC" class="titulo">Lengua target 23</td>
  181.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 23']; ?></td>
  182.   </tr>
  183.   <tr>
  184.     <td bgcolor="#0000CC" class="titulo">Lengua target 24</td>
  185.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Lengua target 24']; ?></td>
  186.   </tr>
  187.   <tr>
  188.     <td bgcolor="#0000CC" class="titulo">Precio por palabra</td>
  189.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Precio por palabra']; ?></td>
  190.   </tr>
  191.   <tr>
  192.     <td bgcolor="#0000CC" class="titulo">Nombre del archivo</td>
  193.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Nombre del archivo']; ?></td>
  194.   </tr>
  195.   <tr>
  196.     <td bgcolor="#0000CC" class="titulo">Numero de palabras nuevas</td>
  197.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Numero de palabras nuevas']; ?></td>
  198.   </tr>
  199.   <tr>
  200.     <td bgcolor="#0000CC" class="titulo">Numero de palabras coincidentes</td>
  201.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Numero de palabras coincidentes']; ?></td>
  202.   </tr>
  203.   <tr>
  204.     <td bgcolor="#0000CC" class="titulo">Numero de palabras repetidas</td>
  205.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Numero de palabras repetidas']; ?></td>
  206.   </tr>
  207.   <tr>
  208.     <td bgcolor="#0000CC" class="titulo">Importe total</td>
  209.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Importe total']; ?></td>
  210.   </tr>
  211.   <tr>
  212.     <td bgcolor="#0000CC" class="titulo">Plazo</td>
  213.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Plazo']; ?></td>
  214.   </tr>
  215.    <tr>
  216.     <td bgcolor="#0000CC" class="titulo">IVA</td>
  217.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['IVA']; ?></td>
  218.   </tr>
  219.   <tr>
  220.     <td bgcolor="#0000CC" class="titulo">Datos de facturacion</td>
  221.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Datos de facturacion']; ?></td>
  222.   </tr>
  223.   <tr>
  224.     <td bgcolor="#0000CC" class="titulo">Nota</td>
  225.     <td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Nota']; ?></td>
  226.   </tr>
  227. </table>
  228.  
  229. [COLOR="Red"]
  230. <script type="text/javascript">
  231.  
  232.  
  233. var filas = document.getElementsByTagName("tr"),
  234.     total = filas.length,
  235.     boton = document.getElementsByTagName("button")[0];
  236.  
  237. boton.addEventListener("click", function(){
  238.     for (i = 0; i < total; i++){
  239.         var celda = filas[i].getElementsByTagName("td")[0];
  240.         if (!celda.innerHTML.length)
  241.             filas[i].style.height = "none";
  242.     }
  243. }, false);
  244. </script>
  245. [/COLOR]
  246. <button>Eliminar</button>
  247. </body>
  248. </html><?php
  249. mysql_free_result($DetailRS1);
  250. ?>
  251. </br></br>
  252. <input type="button" value="Volver atrás" onClick="location.href='http://localhost/SIENS/admin/VistaPresupuestos(pgmaestra).php';" style="font-family: Verdana; font-size: 10 pt"/>

Etiquetas: fila, valor
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 13:12.