par
Albat90 » 19 févr. 2007, 17:49
Merci pour ton aide Ryle, ça fonctionne très bien, voici mon script :
<?php
session_start();
$base = "localhost";
$user = "root";
$mdp = "";
$bdd = "bij";
$connect = mysql_connect($base, $user, $mdp) or die("impossible de se connecter");
mysql_select_db($bdd, $connect) or die("impossible de selectionner la BDD");
echo '<table border="1">
<tr align="center" valign="middle">
<td width="100" height="50"><b>identifiant</td>
<td width="100" height="50"><b>Titre</td>
<td width="100" height="50"><b>Nom</td>
<td width="100" height="50"><b>Prenom</td>
<td width="100" height="50"><b>Adresse</td>
<td width="100" height="50"><b>Code Postale </td>
<td width="100" height="50"><b>Ville</td>
<td width="100" height="50"><b>Téléphone</td>
<td width="100" height="50"><b>Adhésion</td>
</tr>';
$sql1 = "SELECT adhesion_proprio.date, proprio.id, proprio.titre, proprio.nom, proprio.prenom, proprio.adresse, proprio.cp, proprio.ville, proprio.tel1
From proprio, adhesion_proprio
WHERE cp >= '90000' AND cp < '91000' AND proprio.id = adhesion_proprio.idproprio ORDER BY nom ASC";
$query = mysql_query($sql1) or die('Erreur SQL !'.$sql.''.mysql_error());
$i = 0;
while($data = mysql_fetch_array($query)){
echo '<tr align="center" valign="middle">
<td width="100" height="50">'.$data['id'].'</td>
<td width="100" height="50">'.$data['titre'].'</td>
<td width="100" height="50">'.$data['nom'].'</td>
<td width="100" height="50">'.$data['prenom'].'</td>
<td width="100" height="50">'.$data['adresse'].'</td>
<td width="100" height="50">'.$data['cp'].'</td>
<td width="100" height="50">'.$data['ville'].'</td>
<td width="100" height="50">'.$data['tel1'].'</td>
<td width="100" height="50">'.$data['date'].'</td>
</tr>';
$i++;
}
echo '</table>
il y a '.$i.' propriétaires dans le territoire de Belfort.';
?>
Si j'ai donnée mon script ce n'est pas pour rien :p
c'est parceque je rencontre un autre problème, vue que j'ai plusieurs date d'adhesion (2005, 2006, 2007), donc il me répète à chaque fois le nom prenom etc... donc je me retrouve à chaque fois avec trois prenom identique etc au lieu d'une seule fois.
est-ce que c'est bon de faire un boucle dans une boucle en php/MySQL???
Merci de vos réponses

Merci pour ton aide Ryle, ça fonctionne très bien, voici mon script :
[php]
<?php
session_start();
$base = "localhost";
$user = "root";
$mdp = "";
$bdd = "bij";
$connect = mysql_connect($base, $user, $mdp) or die("impossible de se connecter");
mysql_select_db($bdd, $connect) or die("impossible de selectionner la BDD");
echo '<table border="1">
<tr align="center" valign="middle">
<td width="100" height="50"><b>identifiant</td>
<td width="100" height="50"><b>Titre</td>
<td width="100" height="50"><b>Nom</td>
<td width="100" height="50"><b>Prenom</td>
<td width="100" height="50"><b>Adresse</td>
<td width="100" height="50"><b>Code Postale </td>
<td width="100" height="50"><b>Ville</td>
<td width="100" height="50"><b>Téléphone</td>
<td width="100" height="50"><b>Adhésion</td>
</tr>';
$sql1 = "SELECT adhesion_proprio.date, proprio.id, proprio.titre, proprio.nom, proprio.prenom, proprio.adresse, proprio.cp, proprio.ville, proprio.tel1
From proprio, adhesion_proprio
WHERE cp >= '90000' AND cp < '91000' AND proprio.id = adhesion_proprio.idproprio ORDER BY nom ASC";
$query = mysql_query($sql1) or die('Erreur SQL !'.$sql.''.mysql_error());
$i = 0;
while($data = mysql_fetch_array($query)){
echo '<tr align="center" valign="middle">
<td width="100" height="50">'.$data['id'].'</td>
<td width="100" height="50">'.$data['titre'].'</td>
<td width="100" height="50">'.$data['nom'].'</td>
<td width="100" height="50">'.$data['prenom'].'</td>
<td width="100" height="50">'.$data['adresse'].'</td>
<td width="100" height="50">'.$data['cp'].'</td>
<td width="100" height="50">'.$data['ville'].'</td>
<td width="100" height="50">'.$data['tel1'].'</td>
<td width="100" height="50">'.$data['date'].'</td>
</tr>';
$i++;
}
echo '</table>
il y a '.$i.' propriétaires dans le territoire de Belfort.';
?>
[/php]
Si j'ai donnée mon script ce n'est pas pour rien :p
c'est parceque je rencontre un autre problème, vue que j'ai plusieurs date d'adhesion (2005, 2006, 2007), donc il me répète à chaque fois le nom prenom etc... donc je me retrouve à chaque fois avec trois prenom identique etc au lieu d'une seule fois.
est-ce que c'est bon de faire un boucle dans une boucle en php/MySQL???
Merci de vos réponses ;)