Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/12/2015, 01:11
Varillas99
 
Fecha de Ingreso: diciembre-2015
Mensajes: 1
Antigüedad: 8 años, 4 meses
Puntos: 0
Problemas con codigo, enlazar paginas php

Hola Compañeros,

Estoy estancado en una parte de mi codigo para realizar una tienda online, quiero mostrar el catalogo de mis productos, y he conseguido enlazarlos a una misma pagina una vez que pinchas... Pagina catalogo_ver.

Me gustaria que se mostrara la lista completa de categorias y segun en la que pinche vaya a una u otra.

lo he intentando hacer con un switch pasandole como parametro row_Recordset1['idCategoria']; pero me da fallo en el codigo.

Ejemplo:

- Lo que pasa Actualmente

CATEGORIAS
- Pantalones --> Se dirije a categorias_ver.php_RecordSet1
- Camisetas --> Se dirije a categorias_ver.php_RecordSet2
- Manga Corta --> Se dirije a categorias_ve.phpr_RecordSet3
- Manga Larga --> Se dirije a categorias_ver.php_RecordSet4
- Abrigos --> Se dirije a categorias_ver.php_RecordSet5

Lo que me gustaria que pasase
- Pantalones --> Se dirija a pantalones.php
- Camisetas --> Se dirija a camisetas.php
- Manga Corta (subcategorias) --> Se dirija a manga_corta.php
- Manga Larga (subcategorias) --> Se dirija a manga_larga.php
- Abrigos --> Se dirija a Abrigos.php


CODIGO
*******

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_conexion, $conexion);
$query_Recordset1 = "SELECT * FROM tblcategoria WHERE idPadre = 0 ORDER BY tblcategoria.strDescripcion";
$Recordset1 = mysql_query($query_Recordset1, $conexionzapatos) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<div class="cabeceracatalogo">CATALOGO</div>
<ul class="listacatalogo">
<?php do { ?>
<li class="lineacatalogo"><a href="categoria_ver.php?cat=<?php echo $row_Recordset1['idCategoria']; ?>"><?php echo $row_Recordset1['strDescripcion']; ?></a></li>
<?php mostrar_subcategorias($row_Recordset1['idCategoria']);?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</ul>
<p>
<?php
mysql_free_result($Recordset1);
?>



function mostrar_subcategorias($identificador)
{

global $database_conexionzapatos, $conexionzapatos;
mysql_select_db($database_conexionzapatos, $conexionzapatos);
$query_ConsultaFuncion = sprintf("SELECT * FROM tblcategoria WHERE idPadre = %s ORDER BY tblcategoria.strDescripcion", $identificador);
$ConsultaFuncion = mysql_query($query_ConsultaFuncion, $conexionzapatos) or die(mysql_error());
$row_ConsultaFuncion = mysql_fetch_assoc($ConsultaFuncion);
$totalRows_ConsultaFuncion = mysql_num_rows($ConsultaFuncion);
?>


<?php
if ($totalRows_ConsultaFuncion > 0) {
do {
echo '<li class="lineacatalogosub"><a href="categoria_ver.php?cat='.$row_ConsultaFuncion['idCategoria'].'">'.$row_ConsultaFuncion['strDescripcion'].'</a></li>';

} while ($row_ConsultaFuncion = mysql_fetch_assoc($ConsultaFuncion));
}

mysql_free_result($ConsultaFuncion);
}