par
bobivienla » 21 déc. 2005, 17:44
ça ne fonctionne tjs pas,
voici mes deux fichiers
Fichier qui liste les contacts
<?php
$dbhost="localhost";
$dblogin="root";
$dbpassword="xxxxx";
$dbname="annuaire";
mysql_connect($dbhost,$dblogin,$dbpassword);
mysql_selectdb($dbname);
$res=mysql_query("SELECT id, nom_type, nom, societe, telephone FROM contact ");
$nbrligne = mysql_num_rows ($res);
$nbrchamp=mysql_num_fields($res);
echo"<br>";
echo"<br>";
echo"<br>";
echo "<p><p><table border=4 align=bottom cellpadding=6 cellspacing=2 width=\100%\">";
for ($i=0;$i<5;$i++) {
printf("<th>%s</th>",mysql_field_name($res,$i));
}
echo "<th>Fiche détaillée</th>";
for ($i=0;$i<$nbrligne;$i++)
{
$row=mysql_fetch_row($res);
echo "<tr>";
foreach($row as $col)
{
if (!$col) $col=" ";
echo "<td>$col</td>";
}
echo "<td><a href=fiche.php?id=".$id.">détails</td>";
echo "</tr>";
}
echo "</table>";
?>
Fiche détaillée d'un contact
<?php
$dbhost="localhost";
$dblogin="root";
$dbpassword="xxxxx";
$dbname="annuaire";
$id = (isset($_GET['id']) ? $_GET['id'] : "id non défini");
echo $id;
//$id=$_GET["id"];
mysql_connect($dbhost,$dblogin,$dbpassword);
mysql_select_db($dbname);
$result=mysql_query("SELECT * FROM contact WHERE id='$id'");
if ($row=mysql_fetch_array($result))
{
echo "Type : " . $row["nom_type"] . "<br>";
echo "Nom : " . $row["nom"] . "<br>";
echo "Societe : " . $row["societe"] . "<br>";
echo "Adresse : " . $row["adresse"] . "<br>";
echo "Code postal : " . $row["codepostal"] . "<br>";
echo "Ville : " . $row["ville"] . "<br>";
echo "Pays : " . $row["pays"] . "<br>";
echo "Telephone : " . $row["telephone"] . "<br>";
echo "Fax : " . $row["fax"] . "<br>";
echo "Fonction : " . $row["fonction"] . "<br>";
echo "E-mail : " . $row["email"] . "<br>";
echo "Portable : " . $row["portable"] . "<br>";
echo "Secrétaire : " . $row["secretaire"] . "<br>";
echo "Service : " . $row["service"] . "<br>";
} else {
echo "Désolé, mais cet utilisateur est inconnu<br>";
}
mysql_close();
?>
ça ne fonctionne tjs pas,
voici mes deux fichiers
[u]Fichier qui liste les contacts[/u]
[php]<?php
$dbhost="localhost";
$dblogin="root";
$dbpassword="xxxxx";
$dbname="annuaire";
mysql_connect($dbhost,$dblogin,$dbpassword);
mysql_selectdb($dbname);
$res=mysql_query("SELECT id, nom_type, nom, societe, telephone FROM contact ");
$nbrligne = mysql_num_rows ($res);
$nbrchamp=mysql_num_fields($res);
echo"<br>";
echo"<br>";
echo"<br>";
echo "<p><p><table border=4 align=bottom cellpadding=6 cellspacing=2 width=\100%\">";
for ($i=0;$i<5;$i++) {
printf("<th>%s</th>",mysql_field_name($res,$i));
}
echo "<th>Fiche détaillée</th>";
for ($i=0;$i<$nbrligne;$i++)
{
$row=mysql_fetch_row($res);
echo "<tr>";
foreach($row as $col)
{
if (!$col) $col=" ";
echo "<td>$col</td>";
}
echo "<td><a href=fiche.php?id=".$id.">détails</td>";
echo "</tr>";
}
echo "</table>";
?>[/php]
[u]Fiche détaillée d'un contact[/u]
[php]<?php
$dbhost="localhost";
$dblogin="root";
$dbpassword="xxxxx";
$dbname="annuaire";
$id = (isset($_GET['id']) ? $_GET['id'] : "id non défini");
echo $id;
//$id=$_GET["id"];
mysql_connect($dbhost,$dblogin,$dbpassword);
mysql_select_db($dbname);
$result=mysql_query("SELECT * FROM contact WHERE id='$id'");
if ($row=mysql_fetch_array($result))
{
echo "Type : " . $row["nom_type"] . "<br>";
echo "Nom : " . $row["nom"] . "<br>";
echo "Societe : " . $row["societe"] . "<br>";
echo "Adresse : " . $row["adresse"] . "<br>";
echo "Code postal : " . $row["codepostal"] . "<br>";
echo "Ville : " . $row["ville"] . "<br>";
echo "Pays : " . $row["pays"] . "<br>";
echo "Telephone : " . $row["telephone"] . "<br>";
echo "Fax : " . $row["fax"] . "<br>";
echo "Fonction : " . $row["fonction"] . "<br>";
echo "E-mail : " . $row["email"] . "<br>";
echo "Portable : " . $row["portable"] . "<br>";
echo "Secrétaire : " . $row["secretaire"] . "<br>";
echo "Service : " . $row["service"] . "<br>";
} else {
echo "Désolé, mais cet utilisateur est inconnu<br>";
}
mysql_close();
?>[/php]