Jip Jip Jip
Invité n'ayant pas de compte PHPfrance
16 mars 2010, 19:37
J'ai bien compris qu'il fallait se connecter dans un premier temps, ca marche nickel dans le meme fichier mais pas dans 2 différents.
Revoici donc les 2 fichiers :
stagiaires_liste.php :
<?php
include("connexion.php");
//include("fonctions.php");
$q = "SELECT id_stagiaires, nom, prenom, poste, sexe, statut, naissance FROM stagiaires ORDER BY nom";
// echo $q;
$p = mysql_query($q) or die (mysql_error());
while ($row = mysql_fetch_assoc($p))
{
$id[] = $row["id_stagiaires"];
$nom[] = $row["nom"];
$prenom[] = $row["prenom"];
$poste[] = $row["poste"];
$statut[] = $row["statut"];
$naissance[] = $row["naissance"];
$sexe[] = $row["sexe"];
}
$nbtotal = count($id);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Liste des salariés</title>
<style type="text/css">
<!--
.Style1 { font-size: 36px;
font-weight: bold;
font-style: italic;
}
-->
</style>
<style type="text/css">
<!--
.Style1 { font-size: 36px;
font-weight: bold;
font-style: italic;
}
-->
</style>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Style2 {font-size: 24px}
.Style7 {
font-size: 14px;
font-family: Arial, Helvetica, sans-serif;
}
.Style15 {color: #003579}
.Style17 {
font-size: 11px;
font-style: italic;
color: #000000;
font-weight: bold;
}
.Style19 {font-size: 18px; font-weight: bold; color: #7E86B7; }
.Style21 {font-size: 11px}
.Style49 { font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: bold;
color: #000099;
}
-->
</style>
</head>
<body><br>
<table align="left"><tr><td><a href="/salaries/index.htm"><img src="data/accueil.png" width="40" border="0"></a></td><td><span class="Style49">ACCUEIL</span></td>
</tr></table>
<table align="right"><tr><td><a href="javascript:history.back();"><img src="data/precedent.png" width="40" border="0"></td><td><span class="Style49">PREC.</span></td>
</tr></table>
<table width="30%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><div align="center"><span class="Style1 Style2 Style2"><span class="Style7">Liste des salariés </span></span></div></td>
</tr>
<tr>
<td><div align="center"><span class="Style1 Style2 Style2"><img border="0" src="data/lignes026.gif" width="115" height="2"></span></div></td>
</tr>
</table><br><br>
<center><table width="80%" border="0" cellspacing="0" cellpadding="0">
<?php
for ($i=0;$i<$nbtotal;$i++)
{
?>
<tr>
<td width="20">
<div align="right">
<img src="data/<? echo $sexe[$i]?>.jpg" width="50" height="50" align="top" alt="Homme/Femme"><br>
</div></td>
<td>
<div align="right"><table id="<? echo $numero; ?>" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><br><span class="Style15"><?php echo $nom[$i];?> <?php echo $prenom[$i];?></span>
<br><span class="Style17">
<?php echo $poste[$i]; ?> <span class="Style19">/</span> <?php echo $statut[$i];?> <span class="Style19">/</span> <?php echo $naissance[$i];?>
</span>
<hr color="003579" size="1">
<span class="Style17"> </span></td>
<td width="30"><a href="salaries_voir.php?id_salaries=<?php echo $id[$i];?>"><img src="data/loupe.png" align="bottom" border="0" alt="Voir la fiche complète du salarié"></a></td>
</tr>
</table>
</div>
</td>
<td> </td>
</tr>
<?php }
?>
</table> </center>
</body>
</html>
et connexion.php :
<?
$srv = "localhost";
$log = "root";
$pwd= "";
$base = "gestion_presence";
echo "coucou";
$connect=mysql_connect($srv,$log,$pwd) or die ("connexion echoué");
mysql_select_db($base,$connect) or die ("connexion a la base echoué");
?>