Tengo un problema, tengo dos archivos, en uno me esta mostrando los años que tengo registrados, y en otro me aparecen los detalles del año que tengo registrado. osea:
2013
--2013 apoyos
--2013 Pruebas
--2013 etc
el problema es que si doy de alta otro año, si consulto el primer año me esta apareciendo tambien los del Segundo año ejemplo:
2013
--2013 apoyos
--2013 pruebas
--2013 etc
--2014 apoyos
--2014 pruebas
2014
--2013 apoyos
--2013 pruebas
--2013 etc
--2014 apoyos
--2014 pruebas
Necesito que solo me aparesca las del año que se seleccione!!??
espero me puedan ayudar, les pongo el codigo de los dos archivos que estoy utilizando
Listado de Años.php
Código PHP:
<?php session_start();
if($_SESSION['username']==""){
header('location:index.php');
}else{
if($_SESSION['tipo_usu']=='a'){
}else{
header('location:index.php');
}
}
include('php_conexion.php');
$can=mysql_query("SELECT COUNT(DISTINCT nom) as numero FROM productos");
if($dato=mysql_fetch_array($can)){
$numero=$dato['numero'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ver Años</title>
<script type="text/javascript" src="js/jquery.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/whmcs.css" rel="stylesheet">
<style type="text/css">
body {
background-color: #FFFFFF;
}
</style>
<script src="js/whmcs.js"></script>
</head>
<body>
<div class="whmcscontainer">
<div class="contentpadded">
<div class="searchbox">
<form method="post" action="" enctype="multipart/form-data" name="form1" id="form1">
<p>Buscar por Año</p>
<input type="text" name="bus" value=""/>
<input type="submit" value="Buscar" class="btn success" />
</form><br>
</div>
<div class="page-header">
<div class="styled_title">
<h1>Listado de Años</h1></div>
<p>Cantidad de Años Registrados [ <?php echo $numero; ?> ]</p>
</div>
<p>Clic en el año para actualizar y boton Abrir para agregar detalles </p>
<table width="100%" border="0" class="zebra-striped">
<thead>
<tr>
<!-- <td width="7%" class="headerSortdesc"><p>Codigo</p></td>-->
<td width="24%" class="headerSortdesc"><p>Año</p></td>
<!-- <td width="30%" class="headerSortdesc"><p>Descripcion</p></td>
<td width="18%" class="headerSortdesc"><p>Estado</p></td>-->
<!--<td width="10%" class="headerSortdesc"><p>Imagen</p></td>-->
<!--<td width="11%" class="headerSortdesc"> </td>-->
</tr>
</thead>
<tbody>
<?php
if(empty($_POST['bus'])){
$can=mysql_query("SELECT id, nom FROM productos GROUP BY nom");
}else{
$buscar=$_POST['bus'];
$can=mysql_query("SELECT * FROM productos where nom LIKE '$buscar%'");
}
while($dato=mysql_fetch_array($can)){
$codigo=$dato['id'];
?>
<tr>
<!--<td><?php echo $dato['id']; ?></td>-->
<td><a href="lista_productos.php?codigo=<?php echo $codigo; ?>"><?php echo $dato['nom']; ?></a></td>
<!--<td><?php echo $dato['des']; ?></td>
<td><p><span class="<?php echo $clase; ?>"><?php echo $mensaje; ?></span></p></td>-->
<!--<td>
<?php
if (file_exists("foto/".$codigo.".jpg")){
echo '<div align="center"><img src="foto/'.$codigo.'.jpg" width="41" height="41" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="41" height="41" alt=""></div>';
}
?>
</td>-->
<!--<td>
<input type="button" value="Abrir" class="btn primary" onClick="window.location='detalle.php?codigo=<?php echo $dato['id']; ?>'" />
</td>-->
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
Listado de Productos.php
Código PHP:
<?php session_start();
if($_SESSION['username']==""){
header('location:index.php');
}else{
if($_SESSION['tipo_usu']=='a'){
}else{
header('location:index.php');
}
}
include('php_conexion.php');
$can=mysql_query("SELECT COUNT(id) as numero FROM productos");
if($dato=mysql_fetch_array($can)){
$numero=$dato['numero'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Editar Metodos de Pagos</title>
<script type="text/javascript" src="js/jquery.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/whmcs.css" rel="stylesheet">
<style type="text/css">
body {
background-color: #FFFFFF;
}
</style>
<script src="js/whmcs.js"></script>
</head>
<body>
<div class="whmcscontainer">
<div class="contentpadded">
<div class="searchbox">
<form method="post" action="" enctype="multipart/form-data" name="form1" id="form1">
<p>Buscar por Detalle de Año</p>
<input type="text" name="bus" value=""/>
<input type="submit" value="Buscar" class="btn success" />
</form><br>
</div>
<div class="page-header">
<div class="styled_title">
<h1>Listado de Series Documentales</h1></div>
<p>Cantidad de Series Registradas [ <?php echo $numero; ?> ]</p>
</div>
<p>Clic en el año para actualizar y boton Abrir para agregar detalles </p>
<table width="100%" border="0" class="zebra-striped">
<thead>
<tr>
<td width="7%" class="headerSortdesc"><p>Codigo</p></td>
<td width="24%" class="headerSortdesc"><p>Nombre</p></td>
<td width="30%" class="headerSortdesc"><p>Descripcion</p></td>
<td width="18%" class="headerSortdesc"><p>Estado</p></td>
<!--<td width="10%" class="headerSortdesc"><p>Imagen</p></td>-->
<td width="11%" class="headerSortdesc"> </td>
</tr>
</thead>
<tbody>
<?php
if(empty($_POST['bus'])){
$can=mysql_query("SELECT * FROM productos");
}else{
$buscar=$_POST['bus'];
$can=mysql_query("SELECT * FROM productos where nom LIKE '$buscar%'");
}
while($dato=mysql_fetch_array($can)){
if($dato['estado']=='s'){
$clase='label active'; $mensaje='Activo';
}else{
$clase='label unpaid'; $mensaje='No Activo';
}
$codigo=$dato['id'];
?>
<tr>
<td><?php echo $dato['id']; ?></td>
<td><a href="producto.php?codigo=<?php echo $codigo; ?>"><?php echo $dato['nom']; ?></a></td>
<td><?php echo $dato['des']; ?></td>
<td><p><span class="<?php echo $clase; ?>"><?php echo $mensaje; ?></span></p></td>
<!--<td>
<?php
if (file_exists("foto/".$codigo.".jpg")){
echo '<div align="center"><img src="foto/'.$codigo.'.jpg" width="41" height="41" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="41" height="41" alt=""></div>';
}
?>
</td>-->
<td>
<input type="button" value="Abrir" class="btn primary" onClick="window.location='detalle.php?codigo=<?php echo $dato['id']; ?>'" />
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>