DERET Pierre-Yves DERET Pierre-Yves - 28 days ago 7
PHP Question

Collect DYNAMIC data on URL via $_GET without form

I'm currently blocked on a little problem, I think i'm close to the answer, but still didn't managed to got it.

Here is my issue :

I have few a tags on a page, for each giving $id_customer and $id_project on another page, and on this page I want to collect my data on my url because I need it for my next query.

Unfortunately I'm not using a form to give data, so i can't collect via names.

here is my code :

ON Page who send (I guess this is ok there because I have data on URL)

if($result){
while($row = mysqli_fetch_assoc($result)){

$id_client=$row['id_client'];
$id_projet=$row['id_projet'];
$nom=$row['nom'];
$adresse_site=$row['adresse_site'];
$nom_site=$row['nom_site'];
$vignette_site=$row['vignette_site'];
$desc_site=$row['desc_site'];
$en_ligne=$row['en_ligne'];
$_GET['id_client']=$id_client;
$_GET['id_projet']=$id_projet;
?>

<!-- <form method="post" action="projet-in.php" id="form_<?php echo $id_client."-".$id_projet ; ?>">
<input type="hidden" name='client' value="<?php echo $id_client; ?>" />
<input type="hidden" name='projet' value="<?php echo $id_projet; ?>" />
</form> -->
<input type="hidden" name='client' value="<?php echo $id_client; ?>" />
<input type="hidden" name='projet' value="<?php echo $id_projet; ?>" />
<div class="col-xs-12 col-sm-6 col-md-4 bloc-galerie bloc-galerie"><a id="submit" href="projet-in.php?<?php echo $_GET['id_client'].'&'.$_GET['id_projet'] ;?>" />
<span class="hover-galerie">
<p>Site</p>
<p class="texte-rose"><span class="nom-site"><?php echo $nom_site; ?></span><br /><?php echo $adresse_site; ?></p>
<p><?php echo $desc_site; ?></p>
</span>
<img src="images/<?php echo $vignette_site; ?>" alt="<?php echo $nom; ?>" /></a>
</div>
<?php
}

}
else{
echo "NON";
}
?>


THEN ON MY SECOND PAGE (here is the issue) :

include('menu.php');
$id_client=$_GET[0];
$id_projet=$_GET[1];
$query="SELECT * FROM db_clients where id_client=$id_client and id_projet=$id_projet";
$result=mysqli_query($connexion, $query);

if($result){
while($row = mysqli_fetch_assoc($result)){


$adresse_site=$row['adresse_site'];
$nom_site=$row['nom_site'];
$lien_site=$row['lien_site'];
$chapeau=$row['chapeau'];
$devices=$row['devices'];
$img_accueil=$row['img_accueil'];
$img_collection=$row['img_collection'];
$img_produits=$row['img_produits'];
?>


Thank you !

EDIT : I tried $_SESSION but every a tag showed the last recurrence on the Session ofc

Answer

You have to name your params in your url :

href="projet-in.php?idClient=<?php echo $_GET['id_client'].'&idProject='.$_GET['id_projet'] ;?>"

And after, to get it in the project-in page, you have to use the name :

$id_client=$_GET['idClient'];
$id_projet=$_GET['idProject'];