En una pagina se muestra una tabla de una base de datos y por cada fila o linea de registro de la bd hay dos botones uno que sirve para eliminar y otro para editar la mismas linea. Ademas hay un botón que sirve para agregar un nuevo campo.
Al seleccionar cada icono envía los datos correspondiente a una pagina que dependerá que tipo de botón allá oprimido, al oprimir, por ejemplo: el botón editar me tiene que mandar todos los datos de la fila seleccionada por el método post de un form. El problemas es que no envía nada, cual seria el motivo?
Acá esta el código:
Código PHP:
<?php include("includes/conexion.php");
if (isset($_POST['selc_localidad'])&&(isset($_POST['selc_categoria']))){
$post_loc= $_POST['selc_localidad'];
$post_cat= $_POST['selc_categoria'];
}
function mostrar_filtro($row){
$eliminar= $row['id_publicidad'];
$editar= $row['id_publicidad'];
echo "<tr align='left'>
<td> $row[razon_social] </td>
<td> $row[localidad] </td>
<td> $row[direccion] </td>
<td> $row[categoria] </td>
<td>
<input type=image name='editar' src='imagenes/icon/btn_editar.png' width='18' height='24'>
<input type=image name='eliminar' src='imagenes/icon/btn_eliminar.png' width='18' height='24'>
</td>
</tr>";
}
?>
<div id="filtros">
<form name="filtro" action="abm.php" method="post">
Localidad
<select name="selc_localidad">
<?php
$sql_localidad= "select * from bd_localidad order by id";
mysql_query('SET NAMES utf8');//reconoce los caracteres especiales [ñ,á,é,etc.] desde la bd
$result_localidad= mysql_query($sql_localidad);
while ($fila=mysql_fetch_row($result_localidad)){
if($post_loc == $fila['1']){
echo "<option value='".$fila['1']."'".selected."> ".$fila['1']."</option>";
}else{
echo "<option value='".$fila['1']."'> ".$fila['1']."</option>";
}
}
?>
</select>
Categoria
<select name="selc_categoria">
<?php
$sql_categoria= "select * from bd_categoria order by id";
mysql_query('SET NAMES utf8');
$result_categoria= mysql_query($sql_categoria);
while ($fila=mysql_fetch_row($result_categoria)){
if($post_cat == $fila['1']){
echo "<option value='".$fila['1']."'".selected."> ".$fila['1']."</option>";
}else{
echo "<option value='".$fila['1']."'> ".$fila['1']."</option>";
}
}
?>
</select>
<button type="submit" name="aceptar" id="aceptar">Filtrar</button>
</form>
</div>
<div id="grilla">
<form name="frm_grilla" action="tb_registro.php" method="post">
<?php
$sql= "SELECT * from bd_publicidad";
$result = mysql_query($sql,$conexion);
if(!$result){die('Ocurrio un error al obtener los valores de la base de datos: ' . mysql_error());}
echo "<table border='1' style= 'width:100%''>";
/*Priemro los encabezados*/
echo "<tr align='center'>
<td>NEGOCIO</td>
<td>LOCALIDAD</td>
<td>DIRECCION</td>
<td>CATEGORIA</td>
<td>
<input type=image name='agregar' title='Agregar registro' src='imagenes/icon/btn_agregar.png' width='18' height='24'>
</td>
</tr> ";
/*Y ahora todos los registros */
while($row=mysql_fetch_array($result))
{
if ($row['sw'] > 0){
if (isset($_POST['selc_localidad'])&&(isset($_POST['selc_categoria']))) {
$row_loc= $row['localidad'];
$row_cat= $row['categoria'];
if (($post_loc == 'Sin filtro')&&($post_cat == 'Sin filtro')) //sin filtrar
{
mostrar_filtro($row);
}else if ((($post_loc == $row_loc)&&($post_cat == $row_cat))) //filtro doble
{
mostrar_filtro($row);
}else if ((($post_loc == $row_loc)&&($post_cat =='Sin filtro'))) //filtro de localidad
{
mostrar_filtro($row);
}else if ((($post_loc == 'Sin filtro')&&($post_cat == $row_cat))) //filtro de categoria
{
mostrar_filtro($row);
}
}
else{
mostrar_filtro($row);
}
}
}
echo "</table>";
mysql_close($conexion);
?>
</form>
</div>