Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/01/2013, 10:55
levistubbs
 
Fecha de Ingreso: enero-2013
Mensajes: 6
Antigüedad: 11 años, 4 meses
Puntos: 1
Aplicar css a enlace activo de menu dinàmico a partir de registros de tabla

Hola a todos,

Soy nuevo usuario en foros del web pero hace mucho que vengo utilizando sus consejos y siempre me han sido de gran ayuda, muchas gracias
Me encuentro con un problema para el que no tengo solución ahora mismo, disculpen si ya se ha tratado, no consigo encontrarlo en el foro
Tengo un menu a partir de los regitros de una tabla que enlazan a la sección del menú a través de la url, querría aplicar una clase al registro activo, es decir a la página en la que me encuentre, por favor podrían ayudarme con esto
El caso sería que si te encuentras en la url: /menu.php?id_section=5&id_lang=1 el registro con id_section=5 utilizase la clase .active


muchas gracias de antemano
el código del menu es el siguiente (trabajo con dreamweaver):


Archivo: menu.php


Código PHP:
<?php require_once('Connections/conexion.php'); ?>
<?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;
}
}

$colname_section_lang "-1";
if (isset(
$_GET['id_lang'])) {
  
$colname_section_lang $_GET['id_lang'];
}
mysql_select_db($database_conexion$conexion);
$query_section_lang sprintf("SELECT mc_section_lang.id, mc_section_lang.id_section, mc_section_lang.id_lang, mc_section_lang.section_lang  FROM mc_section_lang WHERE id_lang = %s AND id_section >3"GetSQLValueString($colname_section_lang"int"));
$section_lang mysql_query($query_section_lang$conexion) or die(mysql_error());
$row_section_lang mysql_fetch_assoc($section_lang);
$totalRows_section_lang mysql_num_rows($section_lang);
?>
<!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=UTF-8" />
<title>menu</title>
<style type="text/css">
.active {
    font-style: italic;
    font-weight: bold;
    text-transform: uppercase;
    color: #F00;
    text-decoration: none;
}
</style>
</head>

<body>

<div id="submenu">
<ul>
<?php do { ?>
  <li><a href="?id_section=<?php echo $row_section_lang['id_section']; ?>&id_lang=<?php echo $row_section_lang['id_lang']; ?>"><?php echo $row_section_lang['section_lang']; ?></a></li>
  <?php } while ($row_section_lang mysql_fetch_assoc($section_lang)); ?>
</ul>
</div>

</body>
</html>
<?php
mysql_free_result
($section_lang);
?>
Archivo: conexion.php


Código PHP:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conexion "localhost";
$database_conexion "db372898479";
$username_conexion "root";
$password_conexion "";
$conexion mysql_pconnect($hostname_conexion$username_conexion$password_conexion) or trigger_error(mysql_error(),E_USER_ERROR); 
?>