Problème php/mysql

Résolu/Fermé
sarah - Modifié par irongege le 22/09/2010 à 15:29
 sarah - 24 sept. 2010 à 19:57
Bonjour,

je suis entrain de développer une application google map en utilisant php mysql, j'ai fait une boucle for et je veux savoir comment spécifier la ligne à laquelle j'ai aboutit je veux dire par exemple: for (i de 0 à 17) {
a= table.champs(i);
}

je suis nauvice en PHP et javascript, donc je vais mettre ma fonction et si quelqu'un peut me la corriger je serai très reconnaissante :

<script type="text/javascript">
function showmarker(){
var info;
if (document.getElementById('0')){ // pour le bouton radio

for (var i=1;i< <?php $totalRows_region ?> + 1 ;i++){
if(c1.checked){ // checkbox dont name=c1
info + = "Nombre d'adherents :" + <?php echo $row_nombre_adherent_region['count( adherent.id )']; ?>;// $row_nombre_adherent_region est un jeu d'enregistrement créé //sous dreamweaver dont ['count( adherent.id )'] est un champs et justement je veux faire //ici [i] mais je ne sais pas comment
}
if(c2.checked){
info + = "Nombre selon la caisse :" + <?php echo $row_caisse_adherent_region['caisse']; ?> + " :" + <?php echo $row_caisse_adherent_region['count( adherent.id )']; ?> ;
}
if(c3.checked){
info + = "Nombre selon sexe :" + <?php echo $row_sexe_adherent_region['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_region['count( adherent.id )']; ?> ;
}
if(c4.checked){
info + = "La moyenne de l'âge :" + <?php echo $row_age_adherent_region['AVG(adherent.age)']; ?> ;
}
if(c5.checked){
info + = "Nombre selon le statut :" + <?php echo $row_statut_adherent_region['statut']; ?> + " :" + <?php echo $row_statut_adherent_region['count( adherent.id )']; ?> ;
}
var point = new GLatLng('<?php echo $row_region['y_r']; ?>','<?php echo $row_region['x_r']; ?>')
map.addOverlay(createMarker(point ,info);
}

}



</script>

Merci d'avance

A voir également:

8 réponses

varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
22 sept. 2010 à 15:01
Salut,

deja voici ta partie script un peu corrigé:

<script type="text/javascript">
function showmarker()
{
    var info = "";
    if (document.getElementById('0'))
    { // pour le bouton radio
        for (var i=1;i< <?php $totalRows_region ?> + 1 ;i++)
        {
            if(c1.checked)
            { // checkbox dont name=c1
                info += "Nombre d'adherents :" + <?php echo $row_nombre_adherent_region['count( adherent.id )']; ?>;
            }
            if(c2.checked)
            {
                info += "Nombre selon la caisse :" + <?php echo $row_caisse_adherent_region['caisse']; ?> + " :" + <?php echo $row_caisse_adherent_region['count( adherent.id )']; ?> ;
            }
            if(c3.checked)
            {
                info += "Nombre selon sexe :" + <?php echo $row_sexe_adherent_region['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_region['count( adherent.id )']; ?> ;
            }
            if(c4.checked)
            {
                info += "La moyenne de l'âge :" + <?php echo $row_age_adherent_region['AVG(adherent.age)']; ?> ;
            }
            if(c5.checked)
            {
                info += "Nombre selon le statut :" + <?php echo $row_statut_adherent_region['statut']; ?> + " :" + <?php echo $row_statut_adherent_region['count( adherent.id )']; ?> ;
            }
            var point = new GLatLng('<?php echo $row_region['y_r']; ?>','<?php echo $row_region['x_r']; ?>')
            map.addOverlay(createMarker(point ,info);
        }

    }
}
</script>


1
Merci, ce que je veux savoir c'est si je n'aurai pas besoin d'indiquer l'indice pour les champs dans la boucle for et si il va la connaitre tout seul et il va exécuter automatiquement une ligne par ligne?
0
varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
22 sept. 2010 à 15:28
je te conseil d'indiquer l'indice...en faite fait un test avec l'indice, et un test sans, sa ne coute rien et tu sera fixé ;)
0
je vois mais je ne connais pas la syntaxe pour indiquer l'indice dans le code que j'ai fait, merci encore une fois pour tes réponses
0
varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
22 sept. 2010 à 15:44
tu met l'indice entre crochet a la fin de ta variable. exemple;

tableau[1]
0
oui mais dans ce cas ça sera quoi la syntaxe : <?php echo $row_nombre_adherent_region['count( adherent.id )']; ?> ??
0
varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
22 sept. 2010 à 15:54
enleve les guillement, et fait un echo de count( adherent.id ) pour vérifier que ça retourne bien un nombre:
<?php 
echo count( adherent.id ); //si sa retourne un nombre, la suite va marcher, sinon ça marchera pas
echo $row_nombre_adherent_region[count( adherent.id )];
 ?>
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Merci bien, oui ça marche il me reste mtn un problème d'affichage des marqueurs sur la carte google map, je vé chercher à résoudre ailleur,

Merci beaucoup pour tout
0
varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
22 sept. 2010 à 16:52
google map je connais :)

tu utilise l'api v2 ou v3?

je peut te montrer ce que j'ai fait:
sur code source, j'ai mis a disposition une méthode pour justement pouvoir utiliser toute les foncrtionnalitées de google map apui v3 des marqueur:

http://www.javascriptfr.com
0
j'utilise l'api v2 :s et il me reste pas bcp de temps et j'ai peur que si je change tout je ne pourrai pas rendre le travail à temps , mais je vais voir ton code quand meme :)
0
comme j'ai dit avant je suis vrmt nauvice en tt ça donc j'ai peur de ne pas pouvoir terminer tout avant une semaine, alors si tu as un exemple utilisant l'api 2 permettant d'afficher plusieurs marqueurs à partir d'une base de données il sera welcome sachant que j'ai déjà effectué un code mais je ne sais pas pourquoi je n'ai pas les marqueurs affichés.

je te remercie infiniment pour tous tes conseils et réponses
0
varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
23 sept. 2010 à 09:05
ben moi je suis stagiaire aussi et je devais de meme que toi afficher des marqueur sur une carte de google map a partir d'une base de données^^ c'est marrant ça. Par contre j'ai utilisé l'api v3, donc je ne connait pas trop l'api v2.

Envoi le code html généré par ton php ainsi que ton fichier javascript, je vais essayer de voir ou sa passe pas.
0
dacc meri bcp ben voilà j'ai mis tout sur un seul fichier qui est html je vais le copier ici, merci d'avance :

<?php require_once('Connections/conn_rcar.php'); ?>
<?php
mysql_select_db($database_conn_rcar, $conn_rcar);
$query_region = "SELECT * FROM region";
$region = mysql_query($query_region, $conn_rcar) or die(mysql_error());
$row_region = mysql_fetch_assoc($region);
$totalRows_region = mysql_num_rows($region);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_coordsville = "select nom_v,x_v,y_v,caisse,sexe,age,statut,rc,rg from ville,adherent where ville.nom_v = adherent.ville";
$coordsville = mysql_query($query_coordsville, $conn_rcar) or die(mysql_error());
$row_coordsville = mysql_fetch_assoc($coordsville);
$totalRows_coordsville = mysql_num_rows($coordsville);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_coordsregion = "SELECT region.nom_r,x_r,y_r,caisse,sexe,age,statut,rc,rg FROM region,adherent WHERE region.nom_r = adherent.nom_r";
$coordsregion = mysql_query($query_coordsregion, $conn_rcar) or die(mysql_error());
$row_coordsregion = mysql_fetch_assoc($coordsregion);
$totalRows_coordsregion = mysql_num_rows($coordsregion);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_nombre_adherent_region = "SELECT adherent.nom_r, x_r, y_r, count( adherent.id ) FROM adherent, region where adherent.nom_r=region.nom_r GROUP BY adherent.nom_r ";
$nombre_adherent_region = mysql_query($query_nombre_adherent_region, $conn_rcar) or die(mysql_error());
$row_nombre_adherent_region = mysql_fetch_assoc($nombre_adherent_region);
$totalRows_nombre_adherent_region = mysql_num_rows($nombre_adherent_region);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_nombre_adherent_ville = "SELECT adherent.ville, x_v, y_v, count( adherent.id ) FROM adherent, ville where adherent.ville=ville.nom_v GROUP BY adherent.ville";
$nombre_adherent_ville = mysql_query($query_nombre_adherent_ville, $conn_rcar) or die(mysql_error());
$row_nombre_adherent_ville = mysql_fetch_assoc($nombre_adherent_ville);
$totalRows_nombre_adherent_ville = mysql_num_rows($nombre_adherent_ville);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_nombre_adherent_quartier = "SELECT adherent.quartier, x_q, y_q, count( adherent.id ) FROM adherent, quartier where adherent.quartier=quartier.nom_q GROUP BY adherent.quartier";
$nombre_adherent_quartier = mysql_query($query_nombre_adherent_quartier, $conn_rcar) or die(mysql_error());
$row_nombre_adherent_quartier = mysql_fetch_assoc($nombre_adherent_quartier);
$totalRows_nombre_adherent_quartier = mysql_num_rows($nombre_adherent_quartier);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_caisse_adherent_region = "SELECT adherent.nom_r,adherent.caisse, x_r, y_r, count( adherent.id ) FROM adherent, region where adherent.nom_r=region.nom_r GROUP BY adherent.nom_r,adherent.caisse";
$caisse_adherent_region = mysql_query($query_caisse_adherent_region, $conn_rcar) or die(mysql_error());
$row_caisse_adherent_region = mysql_fetch_assoc($caisse_adherent_region);
$totalRows_caisse_adherent_region = mysql_num_rows($caisse_adherent_region);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_caisse_adherent_ville = "SELECT adherent.ville,adherent.caisse, x_v, y_v, count( adherent.id ) FROM adherent, ville WHERE adherent.ville=ville.nom_v GROUP BY adherent.ville,adherent.caisse";
$caisse_adherent_ville = mysql_query($query_caisse_adherent_ville, $conn_rcar) or die(mysql_error());
$row_caisse_adherent_ville = mysql_fetch_assoc($caisse_adherent_ville);
$totalRows_caisse_adherent_ville = mysql_num_rows($caisse_adherent_ville);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_caisse_adherent_quartier = "SELECT adherent.quartier,adherent.caisse, x_q, y_q, count( adherent.id ) FROM adherent, quartier where adherent.quartier=quartier.nom_q GROUP BY adherent.quartier,adherent.caisse";
$caisse_adherent_quartier = mysql_query($query_caisse_adherent_quartier, $conn_rcar) or die(mysql_error());
$row_caisse_adherent_quartier = mysql_fetch_assoc($caisse_adherent_quartier);
$totalRows_caisse_adherent_quartier = mysql_num_rows($caisse_adherent_quartier);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_age_adherent_region = "SELECT adherent.nom_r,AVG(adherent.age), x_r, y_r, count( adherent.id ) FROM adherent, region where adherent.nom_r=region.nom_r GROUP BY adherent.nom_r";
$age_adherent_region = mysql_query($query_age_adherent_region, $conn_rcar) or die(mysql_error());
$row_age_adherent_region = mysql_fetch_assoc($age_adherent_region);
$totalRows_age_adherent_region = mysql_num_rows($age_adherent_region);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_age_adherent_ville = "SELECT adherent.ville,AVG(adherent.age), x_v, y_v, count( adherent.id ) FROM adherent, ville where adherent.ville=ville.nom_v GROUP BY adherent.ville";
$age_adherent_ville = mysql_query($query_age_adherent_ville, $conn_rcar) or die(mysql_error());
$row_age_adherent_ville = mysql_fetch_assoc($age_adherent_ville);
$totalRows_age_adherent_ville = mysql_num_rows($age_adherent_ville);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_age_adherent_quartier = "SELECT adherent.quartier,AVG(adherent.age), x_q, y_q, count( adherent.id ) FROM adherent, quartier where adherent.quartier=quartier.nom_q GROUP BY adherent.quartier";
$age_adherent_quartier = mysql_query($query_age_adherent_quartier, $conn_rcar) or die(mysql_error());
$row_age_adherent_quartier = mysql_fetch_assoc($age_adherent_quartier);
$totalRows_age_adherent_quartier = mysql_num_rows($age_adherent_quartier);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_sexe_adherent_region = "SELECT adherent.nom_r,adherent.sexe, x_r, y_r, count( adherent.id ) FROM adherent, region where adherent.nom_r=region.nom_r GROUP BY adherent.nom_r,adherent.sexe";
$sexe_adherent_region = mysql_query($query_sexe_adherent_region, $conn_rcar) or die(mysql_error());
$row_sexe_adherent_region = mysql_fetch_assoc($sexe_adherent_region);
$totalRows_sexe_adherent_region = mysql_num_rows($sexe_adherent_region);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_sexe_adherent_ville = "SELECT adherent.ville,adherent.sexe, x_v, y_v, count( adherent.id ) FROM adherent, ville where adherent.ville=ville.nom_v GROUP BY adherent.ville,adherent.sexe";
$sexe_adherent_ville = mysql_query($query_sexe_adherent_ville, $conn_rcar) or die(mysql_error());
$row_sexe_adherent_ville = mysql_fetch_assoc($sexe_adherent_ville);
$totalRows_sexe_adherent_ville = mysql_num_rows($sexe_adherent_ville);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_sexe_adherent_quartier = "SELECT adherent.quartier,adherent.sexe, x_q, y_q, count( adherent.id ) FROM adherent, quartier where adherent.quartier=quartier.nom_q GROUP BY adherent.quartier,adherent.sexe";
$sexe_adherent_quartier = mysql_query($query_sexe_adherent_quartier, $conn_rcar) or die(mysql_error());
$row_sexe_adherent_quartier = mysql_fetch_assoc($sexe_adherent_quartier);
$totalRows_sexe_adherent_quartier = mysql_num_rows($sexe_adherent_quartier);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_statut_adherent_region = "SELECT adherent.nom_r,adherent.statut, x_r, y_r, count( adherent.id ) FROM adherent, region WHERE adherent.nom_r=region.nom_r GROUP BY adherent.nom_r,adherent.statut";
$statut_adherent_region = mysql_query($query_statut_adherent_region, $conn_rcar) or die(mysql_error());
$row_statut_adherent_region = mysql_fetch_assoc($statut_adherent_region);
$totalRows_statut_adherent_region = mysql_num_rows($statut_adherent_region);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_statut_adherent_ville = "SELECT adherent.ville,adherent.statut, x_v, y_v, count( adherent.id ) FROM adherent, ville WHERE adherent.ville=ville.nom_v GROUP BY adherent.ville,adherent.statut";
$statut_adherent_ville = mysql_query($query_statut_adherent_ville, $conn_rcar) or die(mysql_error());
$row_statut_adherent_ville = mysql_fetch_assoc($statut_adherent_ville);
$totalRows_statut_adherent_ville = mysql_num_rows($statut_adherent_ville);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_statut_adherent_quartier = "SELECT adherent.quartier,adherent.statut, x_q, y_q, count( adherent.id ) FROM adherent, quartier WHERE adherent.quartier=quartier.nom_q GROUP BY adherent.quartier,adherent.statut";
$statut_adherent_quartier = mysql_query($query_statut_adherent_quartier, $conn_rcar) or die(mysql_error());
$row_statut_adherent_quartier = mysql_fetch_assoc($statut_adherent_quartier);
$totalRows_statut_adherent_quartier = mysql_num_rows($statut_adherent_quartier);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_sum_region_adherent = "select count(distinct nom_r) from adherent";
$sum_region_adherent = mysql_query($query_sum_region_adherent, $conn_rcar) or die(mysql_error());
$row_sum_region_adherent = mysql_fetch_assoc($sum_region_adherent);
$totalRows_sum_region_adherent = mysql_num_rows($sum_region_adherent);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_sum_ville_adherent = "select count(distinct ville) from adherent";
$sum_ville_adherent = mysql_query($query_sum_ville_adherent, $conn_rcar) or die(mysql_error());
$row_sum_ville_adherent = mysql_fetch_assoc($sum_ville_adherent);
$totalRows_sum_ville_adherent = mysql_num_rows($sum_ville_adherent);

mysql_select_db($database_conn_rcar, $conn_rcar);
$query_sum_adherent_quartier = "select count(distinct quartier) from adherent";
$sum_adherent_quartier = mysql_query($query_sum_adherent_quartier, $conn_rcar) or die(mysql_error());
$row_sum_adherent_quartier = mysql_fetch_assoc($sum_adherent_quartier);
$totalRows_sum_adherent_quartier = mysql_num_rows($sum_adherent_quartier);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template_rcar.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Document sans titre</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
.Style4 { font-family: Georgia, "Times New Roman", Times, serif;
color: #FFFFFF;
font-weight: bold;
}
.Style5 {font-family: Georgia, "Times New Roman", Times, serif; color: #006666; font-weight: bold; }
.Style6 {font-family: Georgia, "Times New Roman", Times, serif; color: #FFFFFF; font-weight: bold; font-size: 16; }
-->
</style>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body,td,th {
color: #000000;
}
body {
background-color: #FFFFFF;
background-image: url(pics/bg_body.jpg);
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.Style1 {font-size: 16}
-->
</style></head>

<body>
<table width="100%" height="100%" border="0" align="center">
<tr>
<td height="152" colspan="7"><span class="Style1">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload2.macromedia.com/get/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="1200" height="150" align="middle" title="banniere">
<param name="movie" value="banniere.swf" />
<param name="quality" value="high" />
<embed src="banniere.swf" width="1200" height="150" align="middle" quality="high" pluginspage="https://get.adobe.com/flashplayer/" type="application/x-shockwave-flash"></embed>
</object>
</span></td>
</tr>
<tr>
<td width="18%"><span class="Style1"></span></td>
<td width="10%" height="42"> </td>
<td width="11%"><!-- InstanceBeginEditable name="EditRegion3" --><a href="index.php" class="Style4">
<label>Accueil</label>
</a><!-- InstanceEndEditable --></td>
<td width="11%"><!-- InstanceBeginEditable name="EditRegion4" --><a href="localiser.php" class="Style5">Décision</a><!-- InstanceEndEditable --></td>
<td width="11%"><!-- InstanceBeginEditable name="EditRegion5" --><a href="contact.htm" class="Style4">Contact</a><!-- InstanceEndEditable --></td>
<td width="22%"> </td>
<td width="17%"> </td>
</tr>

<tr>
<td><span class="Style1"></span></td>
<td height="483" colspan="5"><!-- InstanceBeginEditable name="EditRegion2" -->

<?php require_once('Connections/conn_rcar.php');


session_start();
?>

<script src="http://maps.google.com/..."
type="text/javascript"></script>
<script type="text/javascript">

function load() {
if (GBrowserIsCompatible()) {

var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(34.02, -6.51), 5);
map.addControl(new GSmallMapControl());
map.addControl(new GOverviewMapControl());

function createMarker(point,info) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowTabsHtml(info);
});
return marker;
}


}


}

</script>


<body onload="load()" onunload="GUnload()">


<div id="map" style="width: 100%; height: 350px; overflow: hidden;"></div>



<!-- InstanceEndEditable -->
<p><!-- InstanceBeginEditable name="EditRegion1" -->



<form action="" method="post" name="form1" target="_self" id="form1" onsubmit="showmarker()">
<p>  </p>
<table width="100%" border="0">
<tr>
<td width="21%"><input id="0" type="radio" name="choix" value="r" onchange="radioclick(1)">
Régions</td>
<td width="79%">
<div id="reg" style="display:none">
<input type="checkbox" name="c1" value="checkbox" onclick="showmarker()" />
Nombre
<input type="checkbox" name="c2" value="checkbox" />
Caisse
<input type="checkbox" name="c3" value="checkbox" />
Sexe
<input type="checkbox" name="c4" value="checkbox" />
Age
<input type="checkbox" name="c5" value="checkbox" />
Statut </div></td>
</tr>
<tr>
<td width="21%"><input id="1" type="radio" name="choix" value="v" onclick="radioclick(2)">
Villes</td>
<td width="79%">
<div id="vil" style="display:none">
<input type="checkbox" name="c6" value="checkbox" />
Nombre
<input type="checkbox" name="c7" value="checkbox" />
Caisse
<input type="checkbox" name="c8" value="checkbox" />
Sexe
<input type="checkbox" name="c9" value="checkbox" />
Age
<input type="checkbox" name="c10" value="checkbox" />
Statut </div></td>
</tr>
<tr>
<td><input id="2" type="radio" name="choix" value="q" onclick="radioclick(3)" />
Quartiers</td>
<td><div id="qar" style="display:none">
<input type="checkbox" name="c11" value="checkbox" />
Nombre
<input type="checkbox" name="c12" value="checkbox" />
Caisse
<input type="checkbox" name="c13" value="checkbox" />
Sexe
<input type="checkbox" name="c14" value="checkbox" />
Age
<input type="checkbox" name="c15" value="checkbox" />
Statut </div></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Afficher" onclick="showmarker()" /></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>



</form>


<script type="text/javascript">

function radioclick (b)

{

document.getElementById('reg').style.display = (b!=1? 'none':'block');

document.getElementById('vil').style.display = (b!=2? 'none':'block');

document.getElementById('qar').style.display = (b!=3? 'none':'block');

}




</script>






<!-- InstanceEndEditable --></p></td>
<td> </td>
</tr>

<tr>
<td height="105" colspan="7"><span class="Style1"></span></td>
</tr>
</table>
</body>
<!-- InstanceEnd -->
<script type="text/javascript">

function showmarker()
{
var info = "";
if (document.getElementById('0'))
{
for (var i=1;i< <?php echo $row_sum_region_adherent['count(distinct nom_r)']; ?> + 1 ;i++)
{
if(c1.checked)
{
info += "Nombre d'adherents :" + <?php echo $row_nombre_adherent_region['count( adherent.id )']; ?>;
var point = new GLatLng('<?php echo $row_nombre_adherent_region['y_r']; ?>','<?php echo $row_nombre_adherent_region['x_r']; ?>');
}
if(c2.checked)
{
info += "Nombre selon la caisse :" + <?php echo $row_caisse_adherent_region['caisse']; ?> + " :" + <?php echo $row_caisse_adherent_region['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_caisse_adherent_region['y_r']; ?>','<?php echo $row_caisse_adherent_region['x_r']; ?>');
}
if(c3.checked)
{

info += "Nombre selon sexe :" + <?php echo $row_sexe_adherent_region['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_region['count( adherent.id )']; ?> ;
info += "Nombre selon sexe :" + <?php echo $row_sexe_adherent_region['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_region['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_sexe_adherent_region['y_r']; ?>','<?php echo $row_sexe_adherent_region['x_r']; ?>');

}
if(c4.checked)
{
info += "La moyenne de l'âge :" + <?php echo $row_age_adherent_region['AVG(adherent.age)']; ?> ;
var point = new GLatLng('<?php echo $row_age_adherent_region['y_r']; ?>','<?php echo $row_age_adherent_region['x_r']; ?>');
}
if(c5.checked)
{
info += "Nombre selon le statut :" + <?php echo $row_statut_adherent_region['statut']; ?> + " :" + <?php echo $row_statut_adherent_region['count( adherent.id )']; ?> ;
info += "Nombre selon le statut :" + <?php echo $row_statut_adherent_region['statut']; ?> + " :" + <?php echo $row_statut_adherent_region['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_statut_adherent_region['y_r']; ?>','<?php echo $row_statut_adherent_region['x_r']; ?>');

}
map.addOverlay(createMarker(point ,info);
}

}

else if (document.getElementById('1'))
{
for (var i=1;i< <?php echo $row_sum_ville_adherent['count(distinct ville)']; ?> + 1 ;i++)
{
if(c6.checked)
{
info += "Nombre d'adherents :" + <?php echo $row_nombre_adherent_ville['count( adherent.id )']; ?>;
var point = new GLatLng('<?php echo $row_nombre_adherent_ville['y_v']; ?>','<?php echo $row_nombre_adherent_ville['x_v']; ?>');
}
if(c7.checked)
{
info += "Nombre selon la caisse :" + <?php echo $row_caisse_adherent_ville['caisse']; ?> + " :" + <?php echo $row_caisse_adherent_ville['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_caisse_adherent_ville['y_v']; ?>','<?php echo $row_caisse_adherent_ville['x_v']; ?>');
}
if(c8.checked)
{

info += "Nombre selon sexe :" + <?php echo $row_sexe_adherent_ville['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_ville['count( adherent.id )']; ?> ;
info += "Nombre selon sexe :" + <?php echo $row_sexe_adherent_ville['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_ville['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_sexe_adherent_ville['y_v']; ?>','<?php echo $row_sexe_adherent_ville['x_v']; ?>');

}
if(c9.checked)
{
info += "La moyenne de l'âge :" + <?php echo $row_age_adherent_ville['AVG(adherent.age)']; ?> ;
var point = new GLatLng('<?php echo $row_age_adherent_ville['y_v']; ?>','<?php echo $row_age_adherent_ville['x_v']; ?>');
}
if(c10.checked)
{

info += "Nombre selon le statut :" + <?php echo $row_statut_adherent_ville['statut']; ?> + " :" <?php echo $row_statut_adherent_ville['count( adherent.id )']; ?> ;
info += "Nombre selon le statut :" + <?php echo $row_statut_adherent_ville['statut']; ?> + " :" <?php echo $row_statut_adherent_ville['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_statut_adherent_ville['y_v']; ?>','<?php echo $row_statut_adherent_ville['x_v']; ?>');

}

map.addOverlay(createMarker(point ,info);
}

}

else if (document.getElementById('2'))
{
for (var i=1;i< <?php echo $row_sum_adherent_quartier['count(distinct quartier)']; ?> + 1 ;i++)
{
if(c11.checked)
{
info += "Nombre d'adherents :" + <?php echo $row_nombre_adherent_quartier['count( adherent.id )']; ?>;
var point = new GLatLng('<?php echo $row_nombre_adherent_quartier['y_q']; ?>','<?php echo $row_nombre_adherent_quartier['x_q']; ?>');
}
if(c12.checked)
{
info += "Nombre selon la caisse :" + <?php echo $row_caisse_adherent_quartier['caisse']; ?> + " :" + <?php echo $row_caisse_adherent_quartier['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_caisse_adherent_quartier['y_q']; ?>','<?php echo $row_caisse_adherent_quartier['x_q']; ?>');
}
if(c13.checked)
{

info += "Nombre selon sexe :" + <?php echo $row_sexe_adherent_quartier['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_quartier['count( adherent.id )']; ?> ;
info += "Nombre selon sexe :" + <?php echo $row_sexe_adherent_quartier['sexe']; ?> + " :" + <?php echo $row_sexe_adherent_quartier['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_sexe_adherent_quartier['y_q']; ?>','<?php echo $row_sexe_adherent_quartier['x_q']; ?>');

}
if(c14.checked)
{
info += "La moyenne de l'âge :" + <?php echo $row_age_adherent_quartier['AVG(adherent.age)']; ?> ;
var point = new GLatLng('<?php echo $row_age_adherent_quartier['y_q']; ?>','<?php echo $row_age_adherent_quartier['x_q']; ?>');
}
if(c15.checked)
{

info += "Nombre selon le statut :" + <?php echo $row_statut_adherent_quartier['statut']; ?> + " :" <?php echo $row_statut_adherent_quartier['count( adherent.id )']; ?> ;
info += "Nombre selon le statut :" + <?php echo $row_statut_adherent_quartier['statut']; ?> + " :" <?php echo $row_statut_adherent_quartier['count( adherent.id )']; ?> ;
var point = new GLatLng('<?php echo $row_statut_adherent_quartier['y_q']; ?>','<?php echo $row_statut_adherent_quartier['x_q']; ?>');

}

map.addOverlay(createMarker(point ,info);
}

}
}

</script>
</html>

<?php
mysql_free_result($region);

mysql_free_result($coordsville);

mysql_free_result($coordsregion);

mysql_free_result($nombre_adherent_region);

mysql_free_result($nombre_adherent_ville);

mysql_free_result($nombre_adherent_quartier);

mysql_free_result($caisse_adherent_region);

mysql_free_result($caisse_adherent_ville);

mysql_free_result($caisse_adherent_quartier);

mysql_free_result($age_adherent_region);

mysql_free_result($age_adherent_ville);

mysql_free_result($age_adherent_quartier);

mysql_free_result($sexe_adherent_region);

mysql_free_result($sexe_adherent_ville);

mysql_free_result($sexe_adherent_quartier);

mysql_free_result($statut_adherent_region);

mysql_free_result($statut_adherent_ville);

mysql_free_result($statut_adherent_quartier);

mysql_free_result($sum_region_adherent);

mysql_free_result($sum_ville_adherent);

mysql_free_result($sum_adherent_quartier);
?>



voilà et j'ai dans la base de données une table adherent, une table region, une table ville et une table quartier
0
je suis vraiment blockée et il me reste qu'une semaine pour rendre mon travail + le rapport et je sais que j'ai des erreurs ici donc merci bcp vrmt.
0
varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
23 sept. 2010 à 11:12
il me faudrait juste le code html généré...

je m'explique:

quand tu génére la page, sa t'affiche bien un truc. sur la page généré, tu fais un click droit et code source de la page. La tu me le fourni, mais en utilisant les balise code de ccm

pour afficher comme ça
0
voilà ce que j'ai comme code source:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template_rcar.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Document sans titre</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
.Style4 {	font-family: Georgia, "Times New Roman", Times, serif;
	color: #FFFFFF;
	font-weight: bold;
}
.Style5 {font-family: Georgia, "Times New Roman", Times, serif; color: #006666; font-weight: bold; }
.Style6 {font-family: Georgia, "Times New Roman", Times, serif; color: #FFFFFF; font-weight: bold; font-size: 16; }
-->
</style>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body,td,th {
	color: #000000;
}
body {
	background-color: #FFFFFF;
	background-image: url(pics/bg_body.jpg);
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.Style1 {font-size: 16}
-->
</style></head>

<body>
<table width="100%" height="100%" border="0" align="center">

  <tr>
    <td height="152" colspan="7"><span class="Style1">
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload2.macromedia.com/get/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="1200" height="150" align="middle" title="banniere">
        <param name="movie" value="banniere.swf" />
        <param name="quality" value="high" />
        <embed src="banniere.swf" width="1200" height="150" align="middle" quality="high" pluginspage="https://get.adobe.com/flashplayer/" type="application/x-shockwave-flash"></embed>
      </object>
    </span></td>
  </tr>

  <tr>
    <td width="18%"><span class="Style1"></span></td>
    <td width="10%" height="42">&nbsp;</td>
    <td width="11%"><!-- InstanceBeginEditable name="EditRegion3" --><a href="index.php" class="Style4">
    <label>Accueil</label>
    </a><!-- InstanceEndEditable --></td>
    <td width="11%"><!-- InstanceBeginEditable name="EditRegion4" --><a href="localiser.php" class="Style5">Décision</a><!-- InstanceEndEditable --></td>

    <td width="11%"><!-- InstanceBeginEditable name="EditRegion5" --><a href="contact.htm" class="Style4">Contact</a><!-- InstanceEndEditable --></td>
    <td width="22%">&nbsp;</td>
    <td width="17%">&nbsp;</td>
  </tr>
  
  <tr>
    <td><span class="Style1"></span></td>
    <td height="483" colspan="5"><!-- InstanceBeginEditable name="EditRegion2" -->
	 
	 	
		<script src="http://maps.google.com/..."
            type="text/javascript"></script>

        <script type="text/javascript">
		
function load() {
 if (GBrowserIsCompatible()) {
 
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(34.02, -6.51), 5);
map.addControl(new GSmallMapControl());
map.addControl(new GOverviewMapControl());

 function createMarker(point,info) {
 var marker = new GMarker(point);
 GEvent.addListener(marker, "click", function() {
 marker.openInfoWindowTabsHtml(info);
 });
 return marker;
 }

 
 }
 


 

 

 

/*
	
							  $query_choice=("SELECT * FROM" + $choice);
							  $choice1 = mysql_query($query_choice, $conn_rcar) or die(mysql_error());
							  $row_choice = mysql_fetch_assoc($choice1);
							  $totalRows_choice = mysql_num_rows($choice1);
							  ?>
							  
							         var urlstr = "./ajax_mysql.php";
       							GDownloadUrl(urlstr, function(data) {
         						var xml = GXml.parse(data);
         						var markers = xml.documentElement.getElementsByTagName("marker");
         						for (var i = 0; i < markers.length; i++) {
         					  	var nom = markers[i].getAttribute("nom");
           						var url = markers[i].getAttribute("url");
           						var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("long")));
           						var marker = createMarker(point,nom,url);
           						map.addOverlay(marker);
         						}
       							});

							   var myIcon = new GIcon();
							  for (var i=1; i<17; i++) {
							   
                                myIcon.image = "http://www.google.com/mapfiles/marker" + i + ".png";
                                myIcon.iconAnchor = new GPoint((markerImage1.width / 2), markerImage1.height);
                                markerOptions = { icon: myIcon, draggable: false };
                                var point1 = new GLatLng(" echo $row_choice['x_r']?>, echo $row_choice['y_r']?>");
                                bounds.extend(point1);
                                setBounds(map, bounds);
                                var marker1 = new GMarker(point1, markerOptions);
                                map.addOverlay(marker1);
                                GEvent.addListener(marker1, "click", function () {

                                    window.open(" echo $row_choice['nom_r']?>");
                                });*/
							  
							   }
						
</script>
 

       <body onload="load()" onunload="GUnload()">
 
	   
	         <div id="map" style="width: 100%; height: 350px; overflow: hidden;"></div>
			 
	
 	
    <!-- InstanceEndEditable -->
      <p><!-- InstanceBeginEditable name="EditRegion1" -->
	  
	  

      <form action="" method="post" name="form1" target="_self" id="form1" onsubmit="showmarker()">
        <p>&nbsp;        </p>

        <table width="100%" border="0">
          <tr>
            <td width="21%"><input id="0" type="radio" name="choix" value="r"  onchange="radioclick(1)">
Régions</td>
            <td width="79%">
			<div id="reg" style="display:none">
			  <input type="checkbox" name="c1" value="checkbox" onclick="showmarker()" />
			  Nombre
			  <input type="checkbox" name="c2" value="checkbox" />

			  Caisse 
			  <input type="checkbox" name="c3" value="checkbox" />
			  Sexe 
			  <input type="checkbox" name="c4" value="checkbox" />
			  Age 
			  <input type="checkbox" name="c5" value="checkbox" />
			  Statut			  </div></td>
          </tr>
          <tr>
             <td width="21%"><input id="1" type="radio" name="choix" value="v" onclick="radioclick(2)"> 

Villes</td>
             <td width="79%">
              <div id="vil" style="display:none">
                <input type="checkbox" name="c6" value="checkbox" />
Nombre
<input type="checkbox" name="c7" value="checkbox" />
Caisse
<input type="checkbox" name="c8" value="checkbox" />
Sexe
<input type="checkbox" name="c9" value="checkbox" />
Age
<input type="checkbox" name="c10" value="checkbox" />
Statut </div></td>

          </tr>
          <tr>
            <td><input id="2" type="radio" name="choix" value="q" onclick="radioclick(3)" />
Quartiers</td>
            <td><div id="qar" style="display:none">
              <input type="checkbox" name="c11" value="checkbox" />
Nombre
<input type="checkbox" name="c12" value="checkbox" />
Caisse
<input type="checkbox" name="c13" value="checkbox" />
Sexe

<input type="checkbox" name="c14" value="checkbox" />
Age
<input type="checkbox" name="c15" value="checkbox" />
Statut </div></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit" value="Afficher" onclick="showmarker()" /></td>
          </tr>
        </table>

        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>      
	  
	       	

      </form>
	  
	  
	  <script type="text/javascript">

function radioclick (b) 

{

	document.getElementById('reg').style.display = (b!=1? 'none':'block');

	document.getElementById('vil').style.display = (b!=2? 'none':'block');

	document.getElementById('qar').style.display = (b!=3? 'none':'block');

}




</script>



	 

	  
    <!-- InstanceEndEditable --></p></td>

    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td height="105" colspan="7"><span class="Style1"></span></td>
  </tr>
</table>
</body>
<!-- InstanceEnd -->
 <script type="text/javascript">

function showmarker()
{
    	       var info = "";
    if (document.form1.choix(0).checked)
    { 
        for (var i=1;i< 16 + 1 ;i++)
        {
            if(c1.checked)
            {
                info += "Nombre d'adherents :" + 934;
				var point = new GLatLng('33,02475995','-7,178080614');
            }
            if(c2.checked)
            {
                info += "Nombre selon la caisse :" + RCAR + " :" + 934 ;
				var point = new GLatLng('33,02475995','-7,178080614');
            }
            if(c3.checked)
            {
			
                info += "Nombre selon sexe :" + F + " :" + 32 ;
				info += "Nombre selon sexe :" + F + " :" + 32 ;
				var point = new GLatLng('33,02475995','-7,178080614');
            
			}
            if(c4.checked)
            {
                info += "La moyenne de l'âge :" + 61.4497 ;
				var point = new GLatLng('33,02475995','-7,178080614');
            }
            if(c5.checked)
            {
			info += "Nombre selon le statut :" + I + " :" + 1 ;
			info += "Nombre selon le statut :" + I + " :" + 1 ;
				var point = new GLatLng('33,02475995','-7,178080614');
            
			}
            map.addOverlay(createMarker(point ,info);
        }

    }
	
	   else if (document.form1.choix(1).checked)
    { 
        for (var i=1;i< 95 + 1 ;i++)
        {
            if(c6.checked)
            { 
                info += "Nombre d'adherents :" + 1;
				var point = new GLatLng('32,20863347','-6,53729081');
            }
            if(c7.checked)
            {
                info += "Nombre selon la caisse :" + RCAR + " :" + 1 ;
				var point = new GLatLng('32,20863347','-6,53729081');
            }
            if(c8.checked)
            {
			
                info += "Nombre selon sexe :" + M + " :" + 1 ;
				info += "Nombre selon sexe :" + M + " :" + 1 ;
				var point = new GLatLng('32,20863347','-6,53729081');
				
            }
            if(c9.checked)
            {
                info += "La moyenne de l'âge :" + 94.0000 ;
				var point = new GLatLng('32,20863347','-6,53729081');
            }
            if(c10.checked)
            {
			
                info += "Nombre selon le statut :" + R + " :" 1 ;
				info += "Nombre selon le statut :" + R + " :" 1 ;
				var point = new GLatLng('32,20863347','-6,53729081');
				
            }
            
            map.addOverlay(createMarker(point ,info);
        }

    }
	
		   else if (document.form1.choix(2).checked)
    { 
        for (var i=1;i< 1 + 1 ;i++)
        {
            if(c11.checked)
            { 
                info += "Nombre d'adherents :" + ;
				var point = new GLatLng('','');
            }
            if(c12.checked)
            {
                info += "Nombre selon la caisse :" +  + " :" +  ;
				var point = new GLatLng('','');
            }
            if(c13.checked)
            {
			
                info += "Nombre selon sexe :" +  + " :" +  ;
				info += "Nombre selon sexe :" +  + " :" +  ;
				var point = new GLatLng('','');
				
            }
            if(c14.checked)
            {
                info += "La moyenne de l'âge :" +  ;
				var point = new GLatLng('','');
            }
            if(c15.checked)
            {
			
                info += "Nombre selon le statut :" +  + " :"  ;
				info += "Nombre selon le statut :" +  + " :"  ;
				var point = new GLatLng('','');
				
            }
            
            map.addOverlay(createMarker(point ,info);
        }

    }
}

</script>
</html>

0
varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
23 sept. 2010 à 12:32
ton code est bizarre, il y a deux balise body qui s'ouvre...
de plus les contenu des balises sont vides.

Je ne sais pas d'ou vient ton probleme, mais pour le resoudre, je te conseil de faire comme moi:

tu génère ta page html, de maniere a avoir la carte que tu veut avec les marqueurs.
A partir de la, tu récupere le code source de la page, et tu le travil dans notepad++.

Utilise aussi internet explorer et son debuguer javascript:
dans outils/options internet/avancé, decoche la case suivante:
désacrtivé le débogage des script(internet explorer)

lors de la génération de ta page, tu saura ainsi d'ou vient ton erreur
0
salut varfendell ,

Merci d'abord pour ton aide précédemment, en faite, j'ai pu résoudre le problème, j'ai tester mon code petit à petit et j'ai pu détecter le prob et ça marche très bien maintenant, j'ai les marqueurs qui s'affichent et tout, mais j'ai encore un tout petit problème et j'espère que tu pourras m'aider, j'utilise des requetes qui retournent des tableaux et j'essaye de les parcourir afin d'afficher les marqueurs mais je ne sais pas prq j'ai seulement la première ligne qui s'executent, bon voilà une petite vue de la fonction dont je veux parcourir toutes les résultats de la requete une par une, peut etre que j'ai besoin d'ajouter un indice quelque part mais je ne sais la syntaxe exactement dans ce cas :

 <script type="text/javascript">

function sm() 
{
 if (document.getElementById(0).checked) 
    { 

        for (var i=0;i<<?php echo $row_sum_region_adherent['count(distinct nom_r)']; ?> ;i++)  
        {
		var info = "";
            if(document.getElementById(3).checked)  
            {
				var n=<?php echo $row_nombre_adherent_region['count( adherent.id )']; ?>;
                info =info + "Nombre d'adherents :" +  n; 
				var point = new GLatLng(<?php echo $row_nombre_adherent_region['x_r']; ?>,<?php echo $row_nombre_adherent_region['y_r']; ?>); 
				createMarker(point ,info);
				}
            }            
    }	

	   }
</script>


pour <?php echo $row_sum_region_adherent['count(distinct nom_r)']; ?> ne retourne qu'une seule valeur et ça marche puisque j'ai le nombre exact des marqueurs affichés, alors que pour les autres je n'ai que la première ligne du résultat qui est executée.

Si quelqu'un peut me donner une solution elle est la bienvenue.

Merci
0