Foros del Web » Programando para Internet » PHP »

master php mysql

Estas en el tema de master php mysql en el foro de PHP en Foros del Web. bueno ante tods tengas buenas tardes el motivo de la presente es para pedir su ayuda con un ejercicio en php mysql ..bueno el prblema ...
  #1 (permalink)  
Antiguo 22/03/2011, 17:00
 
Fecha de Ingreso: agosto-2010
Mensajes: 20
Antigüedad: 13 años, 7 meses
Puntos: 1
master php mysql

bueno ante tods tengas buenas tardes el motivo de la presente es para pedir su ayuda con un ejercicio en php mysql ..bueno el prblema es el siguiente ps estoy dos dias tratando de solucionar un ejercio de php mysql ..bueno ahi les paso le codigo parak chekeen y me ayuden ...el punto es k cuando carog la pagina mantenimientosubcategoria.php el comobobox ( select ) carga perfectamente ..pero cuando CARGO LA pagina /listadosubcategoria.php y le doy la opcion "MODIFICAR" el comobo box no carga las opciones ..me gustaria k me ayudaran a resolver este pekeño problema ..
ahi les paso el ocdigo para k vean k me toy esforzando y si recurro a usteedes es pk ya llevo varios dias con este problema y me urge solucionarlo pk tengo k presentar todo este proyecto para dentro de 3 semanas...

gracias de antemano ...
no se si sera correcto esto ...pero si fuera posible contactarme con personas k me puedan orientar y corregir en este mi proyecto final ..estaria muy agradecido ..
disculpeme si lok pido no es correcto


gracias ...

*********************
listadosubcategoria.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:954px;
height:212px;
z-index:1;
top: 52px;
left: 18px;
}
#Layer2 {
position:absolute;
width:434px;
height:105px;
z-index:1;
top: -28px;
left: 630px;
}
-->
</style>
</head>
<script language="javascript1.2" type="text/javascript">

function validacampo(){
if(document.form2.txtfiltro.value==""){
alert ('ingrese criterio de busqueda ');
}
else{
document.form2.accion="listadosubcategoria.php";
document.form2.submit();}
}
</script>
<body>
<div id="Layer1">
<form id="form1" name="form1" method="post" action="">
<p>&nbsp;</p>
<table width="954" border="0" align="center">
<tr>
<td colspan="6"><div align="center"><strong>LISTADO DE SUBCATEGORIAS DISPONIBLES</strong></div></td>
</tr>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6"><div align="right"><a href="mantenimientosubcategoria.php?accion=INSERTA R"><img src="http://www.forosdelweb.com/f18/imagenes/Add.png" width="32" height="32" border="0" /></a></div></td>
</tr>
<tr>
<td width="74"><strong>Codigo</strong></td>
<td width="244"><strong>Nombre</strong></td>
<td width="219"><strong>Descripcion</strong></td>
<td width="206"><strong>Categoria</strong></td>
<td width="99"><strong>Modificar</strong></td>
<td width="86"><strong>Eliminar</strong></td>
</tr>
<?
$criterio=$_POST['txtfiltro'];
include_once("../classes/subcategoria.php");
$objSubcategoria= new subcategoria();
$result=$objSubcategoria->ListarSubcategoria();

if($_POST['accion']=="FILTRAR"){
$objSubcategoria= new subcategoria();
$result=$objSubcategoria->filtrarSubcategoria($criterio);
}

while($fila=mysql_fetch_array($result)){
?>
<tr>
<td><?= $fila['codsubcategoria'] ?></td>
<td><?= $fila[1] ?></td>
<td><?= $fila['descripcion'] ?></td>
<td><?= $fila[3] ?></td>
<td><a href="mantenimientosubcategoria.php?accion=MODIFIC AR&amp;&amp;cod=<? echo $fila['codsubcategoria'] ?>"><img src="http://www.forosdelweb.com/f18/imagenes/Modify.png" width="20" height="20" border="0" /></a></td>
<td><a href="controlsubcategoria.php?accion=ELIMINAR&amp; &amp;cod=<? echo $fila['codsubcategoria'] ?>"><img src="http://www.forosdelweb.com/f18/imagenes/Delete.png" width="20" height="20" border="0" /></a></td>
</tr>
<?
}
mysql_free_result($result);
?>
</table>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
</div>

</body>
</html>


*****************************************
mantenimientosubcategoria.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>
<script>
function validacampo(){
$mensaje="";
if(document.form1.txtnombre.value==""){
$mensaje=$mensaje+"\n INGRESE NOMBRE";
}

if(document.form1.txtdescripcion.value==""){
$mensaje=$mensaje+"\n INGRESE DESCRIPCION";
}

if(document.form1.selcategoria.value==""){
$mensaje=$mensaje+"\n SELECCONE CATEGORIA";
}
if($mensaje==""){
if (confirm("Esta seguro que desea GUARDAR este registro")){
document.form1.accion="mantenimientosubcategoria.p hp";
document.form1.submit();

}
}else{
alert("Se encontraron los siguientes errores \n"+$mensaje);

}

}

</script>
<style>
#Layer1 {
position:absolute;
width:832px;
height:286px;
z-index:1;
top: 15px;
left: 107px;
}
</style>
<body>

<div id="Layer1">
<form id="form1" name="form1" method="post" action="<? echo 'controlsubcategoria.php?accion='.$_GET['accion'] ?>">


<p>&nbsp;</p>
<table width="693" border="1" align="center">
<tr>
<td colspan="2"><strong>MANTENIMIENTO DE LAS SUBCATEGORIAS </strong></td>
</tr>
<?
if($_GET['accion']=="MODIFICAR"){

include_once("../classes/subcategoria.php");
$objCat= new subcategoria();
$result=$objCat->buscarSubcategoria($_GET['cod']);
$fila=mysql_fetch_array($result);
}
?>

<tr>
<td width="80">Codigo</td>
<td width="175"><label>
<input name="txtcodigo" type="text" id="txtcodigo" value="<? if($_GET['accion']=="MODIFICAR") echo $_GET['cod'] ?>" readonly="" />
</label></td>
</tr>
<tr>
<td>nombre</td>
<td><input name="txtnombre" type="text" id="txtnombre" value="<? if($_GET['accion']=="MODIFICAR") echo $fila['nombre'] ?>" /></td>
</tr>
<tr>
<td>descripcion</td>
<td><input name="txtdescripcion" type="text" id="txtdescripcion" value="<? if($_GET['accion']=="MODIFICAR") echo $fila['descripcion'] ?>" /></td>
</tr>
<tr>
<td>Categoria</td>
<td><label>
<select name="selcategoria" id="selcategoria">
<option value="0">-- SELECCIONE --</option>
<?
include_once("../classes/Categoria.php");

$obj = new Categoria();
$rs = $obj->ListarCategoria2();
while($mostrar= mysql_fetch_array($rs)){
?>
<option value="<?=$mostrar['codcategoria']?>" ><?=$mostrar['nombre']?> </option>
<?
}
mysql_free_result($rs);
?>
</select>
</label></td>
</tr>
<tr>
<td><label>
<input type="button" name="Submit" value="GRABAR" onclick="javascript:validacampo(); " />
</label></td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</form>
</div>
</body>
</html>

**************************
Conexion.php

<?
class Conexion{

function conectar(){
if(!($link=mysql_connect("localhost","root","61922 5"))){

exit();
}

if(!(mysql_select_db("proyecto",$link))){

exit();
}
return $link;
}
}
?>

*********************
Categoria.php

<?
include("Conexion.php");

class Categoria{
private $conn;

function __construct(){
$objConexion=new Conexion();
$this->conn=$objConexion->conectar();

}

function ListarCategoria(){
$sql="SELECT * from categoria ";
$result=mysql_query($sql,$this->conn);
return $result;
}


function ListarCategoria2()
{
$sql = "SELECT codcategoria,nombre FROM categoria";
$result=mysql_query($sql,$this->conn);
return $result;
}

?>


****************************
Subcategoria.php

<?
include("Conexion.php");

class Subcategoria{
private $conn;

function __construct(){
$objConexion=new Conexion();
$this->conn=$objConexion->conectar();

}

function ListarSubcategoria(){
//$sql="SELECT * from subcategoria s inner join categoria c where s.codcategoria=c.codcategoria ";
$sql="SELECT s.codsubcategoria,s.nombre,s.descripcion,c.nombre from subcategoria s inner join categoria c where s.codcategoria=c.codcategoria";
$result=mysql_query($sql,$this->conn);
return $result;
}


***********************

Última edición por lokito1986; 22/03/2011 a las 17:13
  #2 (permalink)  
Antiguo 28/03/2011, 09:58
 
Fecha de Ingreso: agosto-2010
Mensajes: 20
Antigüedad: 13 años, 7 meses
Puntos: 1
Respuesta: master php mysql

gracias a todos por su ayuda ..problema solucionado :)

Etiquetas: master, mysql
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 00:17.