Problèmes d'onglet

aurelie689 Messages postés 7 Statut Membre -  
Ozimandias Messages postés 528 Statut Membre -
Bonjour,
je suis en train de créer un site internet et je rencontre un petit problème : j'ai affiché des onglets sur ma page d'accueil que je souhaite afficher sur mes autres pages, j'ai donc ajouté une boucle php mais depuis mon site ne marche plus avec l'erreur :
Parse error: parse error in C:\wamp\www\Projet Wampserver\index.php on line 56

Voici mon code de page d'accueil avec la ligne 56 en gras :

<html>
<head>
<title> Natural disasters </title>
<!-- lien de la page html avec le fichier css -->
<link href='style.css' rel='stylesheet' type='text/css' />

</head>

<body>
<h1 class='tab2'><center> NATURAL DISASTERS </center></h1>
<hr />
<p><center><font color="#0033CC" size="+2">Natural disasters by the head of first aid dispatching official software of the UNO</font></center></p>
<br />

<table width="1250" class="table" border="0">
<tr>
<td>
<div id="menu">
<ul id="onglets">
<li class="active"><a href="home.php"><center>Home</center></a></li>
<br />
<li><a href="index.php"><center>SOS</center></a></li>
<br />
<li><a href="information.php"><center>Information</center></a></li>
<br />
<li><a href="add.php"><center>Add a new NGO</center></a></li>
<br />
<li><a href="map.php"><center>Map</center></a></li>
<br />
<li><a href="picture.php"><center>Pictures</center></a></li>
</ul>
</div>
</td>
<td>
<p><font size="+3"><center> Welcome to the Management of natural disaster in South-East Asia website </center></font></p>
</td>
</tr>
</table>

<?php
function affiche_menu()
{
//tableau contenant les liens d'accès et le texte à afficher
$tab_menu_lien=array("home.php", "index.php", "information.php", "add.php", "map.php", "pictures.php");
$tab_menu_texte=array("Home", "SOS","Information", "Add a new NGO", "Map", "Pictures");

//informations sur la page
$info=pathinfo($_SERVER['PHP_SELF']);

$menu = "<div id=\"menu\"> <ul id=\"onglets\">"

//boucle qui parcours les deux tableaux
foreach($tab_menu_lien as $cle=>$lien)
{
$menu .= " <li";

// si le nom du fichier correspond à celui pointé par l'indice, alors on l'active
if( $info['basename'] == $lien )
$menu .= " class=\"active\"";

$menu .= "><a href=\"" . $lien . "\">" . $tab_menu_texte[$cle] . "</a></li>\n";
}

$menu .= "</ul>\n</div>";
return $menu;
}
?>

<br />

<center><input class="bouton" type="button" name="lien1" value="START PROCESS" onClick="self.location.href='index.php'" style="background-color:white" style="color:red; font-weight:bold"onclick></center>

</body>
</html>

1 réponse

Ozimandias Messages postés 528 Statut Membre 46
 
Apparement le parcours du tableau lui pose un pb.

perso, je ferais ça avec un compteur et je modifierai le foreach:

$compteur = 0;

foreach($tab_menu_lien as $lien)
{
$menu .= " <li";

// si le nom du fichier correspond à celui pointé par l'indice, alors on l'active
if( $info['basename'] == $lien )
$menu .= " class=\"active\"";

$menu .= "><a href=\"" . $lien . "\">" . $tab_menu_texte[$compteur] . "</a></li>\n";
}
0