Tom's Guide > Forum > Programmation > Appel de fonction javascript+php
Mot :    Pseudo :           
 

Bonjour, voilà j'ai un petit site de recherche interne (qui n'est pas encore en ligne), j'ai une base donnée qui renvoie les réponses souhaiter...jusque là c'est logique :-)

J'ai incorporer un appel de fonction java pour cacher une div et au clic, hop elle apparait..;c'est magique ! ça fonctionne super mais là ou ça coince c'est que lorsque ma bdd trouve plusieurs réponses possible (et c'est le but, je ne veut pas changer cet aspect!) lorsqu'on clic, au lieu d'afficher la div cachée correspondante aux réponses suivantes (chaque réponse à un contenu différent dans la div cachée, celui-ci est générer par php et provient évidemment de ma bdd) il affiche toujours le contenu de la première réponse !

Si je n'ai qu'une réponse pas de soucis mais si j'en ai plusieurs...c'est foutus !, pourtant je n'ai pas d'erreur de syntaxe ou quoi que ce soit qui s'affiche.

Voici mon codage javascript:


function description(){

if (document.getElementById('cadre').style.display=='none'){
document.getElementById('cadre').style.display='';
} else {
document.getElementById('cadre').style.display='none';
}

}


et mon codage php/html:

<?php
if (isset($_POST['nom'])){
if (isset($_POST['commune'])){
if (isset($_POST['cp'])){
if (isset($_POST['type'])){
mysql_connect("localhost","root","mysql" );
mysql_select_db ("belgitopia" );

$avance_nom = $_POST['nom'];
$avance_commune = $_POST['commune'];
$avance_cp = $_POST['cp'];
$avance_type = $_POST['type'];
$avance_sql ="SELECT * FROM recherche WHERE nom LIKE '%$avance_nom%' AND commune LIKE '%$avance_commune%' AND cp LIKE '%$avance_cp%' AND type_activite LIKE '%$avance_type%'";
$avance_req=mysql_query($avance_sql) or die(mysql_error());
mysql_close();
while($avance=mysql_fetch_array($avance_req)){
?>
<hr id="recherche_haut_hr" style="color: #f7b309;">
<table width="100%">
<tr><td><h3><?php echo $avance['type_activite']; ?></h3></td>
<td></td>
<td><h3><?php echo $avance['nom']; ?></h3></td>
<td></td>
<td></td>
<td></td>
<td><a href="<?php echo $avance['lien_site']; ?>" style="color:#f7b309;"><?php echo $avance['lien_site']; ?></a></td>
</tr>
<tr><td width="20%"><img src="<?php echo $avance['image1']; ?>" width="150px"></img></td>
<td width="3%"></td>
<td valign="top" width="16%">
<?php echo $avance['adresse']; ?><br/>
<?php echo $avance['cp']; ?><br/>
<?php echo $avance['commune']; ?></td>
<td width="3%"></td>
<td valign="top" width="40%"><div id="descri" style="border: 1px dotted #f7b309;"><?php echo $avance['descriptions']; ?></div></td>
<td width="3%"></td>
<td valign="top" width="15%"><?php echo $avance['tel'];?> <br/>
<?php echo $avance['fax'];?> <br/>
<?php echo $avance['mail'];?></td>
</tr>
</table>
<div id="sous_descriptif">
<a href="#" onclick="description(); return false;" style="color:#fff;">Plus d'info</a> //fonction java script
</div>
<div id="cadre" style="display:none; border:1px solid #f7b309; padding: 5px;"> //fonction java script
<div id="txt">
<img style="float: right;" src="<?php echo $avance['image2'];?>" width="150px"></img>
<p><?php echo $avance['texte'];?></p>
</div>
<br/><br/><br/>
<hr id="hr_text" style="width: 200px; center;">
<div id="texte_fin">
<table width="100%">
<tr><td valign="top" width="35%"><h4>Horaire</h4>
<td></td>
<td width="35%"><h4>Plan d'accès</h4></td>
</tr>
<tr>
<td valign="top"><?php echo $avance['horaires'];?></td>
<td width="30%"></td>
<td><div id="plan">
<a href="#" onclick="plan(); return false;" style="color: #fff">Voir le plan</a>
</div>
<div id="acces" style="display:none;">
<?php echo $avance['plan_acces'];?>
</div></td>
</tr>
</table>
</div>
<div id="image" style="border: 1px dotted #f7b309; padding: 5px; margin-top: 10px;">
<center><img src="<?php echo $avance['image3']; ?>" width="100px"></img>
<img src="<?php echo $avance['image4']; ?>" width="100px"></img>
<img src="<?php echo $avance['image5']; ?>" width="100px"></img>
<img src="<?php echo $avance['image6']; ?>" width="100px"></img>
<img src="<?php echo $avance['image7']; ?>" width="100px"></img></center>
</div>
</div>
<?php
}
}
}
}
}

?>



Si quelqu'un voit, ou as une idée du problème....je suis prenneuse :-)
Je patoge un peu là....je connais pas très bien java donc bon c'est peut-être une bêtise mais je voit pas trop laquelle !

Donc merci d'avance pour vos réponses, quelles soit bonnes ou mauvaise (tout le monde peut se tromper...la preuve Mdr!


Message édité par caliche le 02-05-2009 à 17:55:23
Liens sponsorisés
Inscrivez-vous ou connectez-vous pour masquer ceci.
Tom's Guide > Forum > Programmation > Appel de fonction javascript+php
Aller à :

Il y a 2894 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici.

Attention

Vous allez répondre sur un sujet resté inactif pendant plus de 6 mois.
Assurez-vous d'apporter des éléments nouveaux à la discussion avant de poursuivre.

Répondre Annuler
Liens