Changer de classe css en fonction de l'url dynamique

Eléphanteau du PHP | 10 Messages

16 déc. 2014, 17:47

hello,

je suis vraiment bloquée sur ce point, voici la page entière, visible sur http://beesub.org/blog/Fanny/tagstest.php :

merci pour votre aide

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
include ('./admin/connect.php');


echo"Test pour voir si la variable arrive : ".$_GET["tag"]."<br>";
if($_GET["tag"]=="all"){$class = "menusurb";} else {$class = "menunorm";}
if($_GET["tag"]== "1"){$class2 = "menusurb";} else {$class2 = "menunorm";}
if($_GET["tag"]== "2"){$class2 = "menusurb";} else {$class2 = "menunorm";}


?>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Travaux par tags - Beesub</title>
<script src="https://ajax.googleapis.com/ajax/libs/j ... ery.min.js" type="text/javascript"></script>
<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
<link rel="stylesheet" href="css/mainew.css" type="text/css" media="screen" />
</head>

<body>
<div id="conteneur">
<div id="fond-menu">
</div>
<div id="nav-tags">
<h3>Tags_____</h3>
<ul>
<li class="<? echo $class ?>"><a href="tagstest.php?tag=all" id="all">&nbsp;ALL&nbsp;</a></li>
<?php
//récupération dynamique des tags
$sqltag="select * from t_tags;";
$rstag=mysql_query($sqltag);
while($enr=mysql_fetch_object($rstag)){
print("<li class='".$class2."'><a href='tagstest.php?tag=".$enr->tags_id."'>&nbsp;".$enr->tags_label."&nbsp;</a></li>");
}
?>
</ul>
</div>

<div id="bloc-fixe-gauche">
<h1><span class="trait">_____</span><a href="index.php">Blog / beesub.org</a></h1>
<h2>Graphic Design & Art Direction</h2>
<span class="surlign">ABOUT</span>
<br />
<p class="about">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc volutpat posuere commodo. Curabitur sit amet euismod purus. Etiam facilisis, odio sed suscipit commodo, magna dolor cursus orci, eget malesuada libero nulla euismod ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed varius luctus dapibus. Proin sapien neque, sodales a dui eleifend, porttitor sollicitudin nisi. Praesent facilisis mauris vel dolor ullamcorper, eu malesuada mi malesuada. Nullam interdum enim ac magna mollis, et varius lectus tempor. Nam tempor dapibus est vitae interdum. Aenean convallis elit mi, sit amet placerat tellus suscipit non. Praesent a rutrum velit, eget tempus ipsum. Proin mattis tristique ornare.</p>
<p id="copyright">
<span class="credit">@ </span>BEESUB.ORG.
<br />
All rights reserved. Unless otherwise indicated, all material on this site is copyrighted.
</p>
</div>

<!--div id="imgtext"></div-->

<div id="contenu">
<div id="thumbnails-works">

<?php


//récupération des posts en rapport avec le tag sélectionné

//Vérification d'une sélection sur le tag ou le post
if(isset($_GET['post_id'])){
$sqlpost="select * from t_post where post_affichage=1 and post_id =".$_GET['post_id']." order by post_id desc;";
}else if(!isset($_GET['tag']) or $_GET['tag']=="all"){
$sqlpost="select * from t_post where post_affichage=1 order by post_id desc;";
}else{
$sqlpost="select * from t_post where post_affichage=1 and post_id in (select post_id from t_tagliens where tags_id =".$_GET['tag'].") order by post_id desc;";
}
$rspost=mysql_query($sqlpost);
$cptpost=mysql_num_rows($rspost);
if($cptpost != 0 )
{
while ($enrpost=mysql_fetch_object($rspost)){
$post_id = $enrpost->post_id;
?>
<div class="thumbnails-img">
<a href="index.php?post_id=<?php echo $post_id;?>"><img src="<?php echo $enrpost->post_image;?>" width ='203px' height='114px'><br />

<span class="titre1"><?php echo $enrpost->post_titre;?></span><br>

<span class="titre2"><?php echo $enrpost->post_soustitre;?></span>
</a>
</div>

<?php
}
}
?>
</div>
</div>

<script type="text/javascript">
$(function() {
$('#thumbnails-works img').css({
'opacity': 1
});
$('#thumbnails-works img').hover(function() {
$(this).animate({
'opacity': .5
});
},
function() {
$(this).animate({
'opacity': 1
});
});
});

$(document).ready(function(){
$("area[rel^='prettyPhoto']").prettyPhoto();

$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:5000, autoplay_slideshow: false,overlay_gallery: false /* If set to true, a gallery will overlay the fullscreen image on mouse over */});
$(".gallery2:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:5000, autoplay_slideshow: false,overlay_gallery: false /* If set to true, a gallery will overlay the fullscreen image on mouse over */});

});
</script>
</body>
</html>