par
Invité » 23 janv. 2008, 15:36
tout d'abord merci pour la réponse,
bon si j'ai bien compris je fait ceçi:
<?php
// connexion a la bdd
function connect() {
global $host,$login,$pass,$base,$mysql_link;
$mysql_link = mysql_connect($host,$login,$pass);
mysql_select_db($base, $mysql_link);
}
connect();
$query = "select * from $table where cp='".$_POST['codepostal']."'";
$resultat = mysql_query($query, $mysql_link);
$res= mysql_num_rows($resultat);
while ($nbr = mysql_fetch_array($resultat)){
$villes =
array(id_ville_1 => array('id'=>..., 'nom'=>..., 'cp'=>...., 'pays'=>....),
id_ville_2 => array('id'=>..., 'nom'=>..., 'cp'=>...., 'pays'=>....),
.... )
;
}
?>
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td height="25" colspan="3" valign="middle">Résultat de votre recherche pour le code postal:
<? if ($res==0){echo "<font color=\"red\">Aucun résultat trouvé pour le code ".$_POST['codepostal']." !!!</font>";} ?></td>
</tr>
<tr>
<td id="entete" width="78" height="20" valign="middle">Code postal</td>
<td id="entete" width="328" valign="middle">Ville</td>
<td id="entete" width="194" valign="middle">Pays</td>
</tr>
<tr>
<td height="20" valign="top"><?=$cp?></td>
<td valign="top"><?php foreach($villes as $id => $infos){?>
<tr>
<td height="20" valign="top"><?php echo $infos['cp'];?></td>
<td valign="top"><?php echo $infos['nom'];?></td>
<td valign="top"><?php echo $infos['pays'];?></td>
</tr>
<?php } ?>
</td>
<td valign="top"><?=$pays?></td>
</tr>
</table>
<? } ?> </td>
</tr>
</table>
</center>
tout d'abord merci pour la réponse,
bon si j'ai bien compris je fait ceçi:
[php]<?php
// connexion a la bdd
function connect() {
global $host,$login,$pass,$base,$mysql_link;
$mysql_link = mysql_connect($host,$login,$pass);
mysql_select_db($base, $mysql_link);
}
connect();
$query = "select * from $table where cp='".$_POST['codepostal']."'";
$resultat = mysql_query($query, $mysql_link);
$res= mysql_num_rows($resultat);
while ($nbr = mysql_fetch_array($resultat)){
$villes =
array(id_ville_1 => array('id'=>..., 'nom'=>..., 'cp'=>...., 'pays'=>....),
id_ville_2 => array('id'=>..., 'nom'=>..., 'cp'=>...., 'pays'=>....),
.... )
;
}
?>
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td height="25" colspan="3" valign="middle">Résultat de votre recherche pour le code postal:
<? if ($res==0){echo "<font color=\"red\">Aucun résultat trouvé pour le code ".$_POST['codepostal']." !!!</font>";} ?></td>
</tr>
<tr>
<td id="entete" width="78" height="20" valign="middle">Code postal</td>
<td id="entete" width="328" valign="middle">Ville</td>
<td id="entete" width="194" valign="middle">Pays</td>
</tr>
<tr>
<td height="20" valign="top"><?=$cp?></td>
<td valign="top"><?php foreach($villes as $id => $infos){?>
<tr>
<td height="20" valign="top"><?php echo $infos['cp'];?></td>
<td valign="top"><?php echo $infos['nom'];?></td>
<td valign="top"><?php echo $infos['pays'];?></td>
</tr>
<?php } ?>
</td>
<td valign="top"><?=$pays?></td>
</tr>
</table>
<? } ?> </td>
</tr>
</table>
</center>[/php]