Diriger une page vers une function()
Résolu/Fermé
sebfitzmaurice
Messages postés
11
Date d'inscription
mercredi 5 mars 2008
Statut
Membre
Dernière intervention
24 mars 2008
-
5 mars 2008 à 17:03
sebfitzmaurice Messages postés 11 Date d'inscription mercredi 5 mars 2008 Statut Membre Dernière intervention 24 mars 2008 - 5 mars 2008 à 18:42
sebfitzmaurice Messages postés 11 Date d'inscription mercredi 5 mars 2008 Statut Membre Dernière intervention 24 mars 2008 - 5 mars 2008 à 18:42
Bonjour,
Je suis débutant, et j'ai besoin d'aide svp!
Je cherche à savoir comment diriger une page.php vers une autre page.php qui, elle inclue un choix de function(), dans le href?
Merci d'avance !
Je suis débutant, et j'ai besoin d'aide svp!
Je cherche à savoir comment diriger une page.php vers une autre page.php qui, elle inclue un choix de function(), dans le href?
Merci d'avance !
A voir également:
- Diriger une page vers une function()
- Supprimer une page word - Guide
- Imprimer tableau excel sur une page - Guide
- Créer une page facebook - Guide
- Comment traduire une page - Guide
- Mettre une page en paysage word - Guide
2 réponses
Emeric84
Messages postés
30
Date d'inscription
vendredi 28 décembre 2007
Statut
Membre
Dernière intervention
24 avril 2008
8
5 mars 2008 à 18:09
5 mars 2008 à 18:09
Je ne suis pas sûr d'avoir bien compris ce que tu veux, je reformules :
Offrir la possibilité à page1.php d'utiliser des fonctions contenues dans page2.php ?
Dans ce cas, c'est très simple, au tout début de page1.php, tu fais :
include('page2.php');
Offrir la possibilité à page1.php d'utiliser des fonctions contenues dans page2.php ?
Dans ce cas, c'est très simple, au tout début de page1.php, tu fais :
include('page2.php');
Emeric84
Messages postés
30
Date d'inscription
vendredi 28 décembre 2007
Statut
Membre
Dernière intervention
24 avril 2008
8
5 mars 2008 à 18:20
5 mars 2008 à 18:20
Qu'est-ce que tu appelles passer par un href ? Passer un paramètre par l'adresse ?
En gros ton problème c'est d'exploiter ton lien :
index.php?page=affiche_choix&velo()
Dans ce cas, tu peux récupérer la valeur avec $_GET :
$_GET['page'] (== 'affiche_choix')
Mais pour récupérer la fonction, tu devrais modifier ton lien en :
index.php?page=affiche_choix&fonction=velo
Du coup tu pourras récupérer 'velo' dans $_GET['fonction']
En gros ton problème c'est d'exploiter ton lien :
index.php?page=affiche_choix&velo()
Dans ce cas, tu peux récupérer la valeur avec $_GET :
$_GET['page'] (== 'affiche_choix')
Mais pour récupérer la fonction, tu devrais modifier ton lien en :
index.php?page=affiche_choix&fonction=velo
Du coup tu pourras récupérer 'velo' dans $_GET['fonction']
sebfitzmaurice
Messages postés
11
Date d'inscription
mercredi 5 mars 2008
Statut
Membre
Dernière intervention
24 mars 2008
5 mars 2008 à 18:42
5 mars 2008 à 18:42
Merci beaucoup Emeric84 pour ta reponse !
Mais comme je le disais je suis encore nouveau en php et j'essaie de faire des miracles , ma ca va quand meme assez bien et j'ai presque terminer mon site, mais faudrait encore que tu m'explique ou mettre le morceau de code $_GET['page'] (== 'affiche_choix')
voici ma page 1 pour te donner une bonne idée !:
<?php
$link = mysql_connect("localhost", "root", "");
mysql_select_db("sport", $link);
?>
<div id="velo"><img src="images/velo.jpg"width="40" height="30" alt="Mon Image"> <a href="index.php?page=affiche_choix&function=velo">velo</a>
<br>Vélo complet
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='velocomplet'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Cadre
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='cadre'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Guidon
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='guidon'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Selle
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='selle'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Roues
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='roues'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Groupo
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='groupo'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Pédalier
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='pedalier'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Autres
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='autresvelo'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
</div>
voici ma page 2 :
<html>
<head>
<title>resultat des annonces</title>
<link rel="stylesheet" href="cssfile/css_annonce.css">
</head>
<body>
<table align=center cellpadding=5>
</table><br><br>
<?php
include("fonction/connection_data.php");
include("fonction/mysql_func.php");
connect();
$_GET['page']== ('affiche_choix')
function velo()
{
$table="annonce";
$annonce=addslashes($annonce);
$sql="select * from $table where categorie = 'velo'";
$res2=mysql_query($sql);
echo "<table width=100% align=center border=>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>DATE</td>";
echo "<td>NOM</td>";
echo "<td>EMAIL</td>";
echo "<td>ANNONCE</td>";
echo "<td>PHOTO</td>";
echo "<td>VOIR</td>";
echo "</tr>";
while ($affiche = mysql_fetch_array($res2))
{
$id =$affiche['nbrann'];
$date=$affiche['date'];
$nom=$affiche['nom'];
$email=$affiche['email'];
$code=$affiche['code'];
$annonce= stripslashes($affiche['annonce']);
$photo=$affiche['photo'];
echo "</tr>";
echo "<td>$id</td>";
echo "<td>$date</td>";
echo "<td>$nom</td>";
echo "<td><a href=\"mailto:$email\"> $email</a></td>";
echo "<td>$annonce</td>";
if ($photo!="")
{
echo "<td><img src=\"C:\wamp\www\ybet\image_annonce/$photo\"
width=\"80\" height=\"80\"></td>";
}
else
{echo "<td><center>no photos</center></td>";}
echo"<td>";
echo"<form method=\"POST\" action=\"index.php?page=affiche_choix\">";
echo"<input name=\"id\" type=\"hidden\" value=\"$id\">";
echo"<input type=\"submit\" value=\"look\">";
echo"</form>";
echo"</td>";
echo "</tr>";
}
echo "</table>";
}
mysql_close();
?>
</body>
</html>
Mais comme je le disais je suis encore nouveau en php et j'essaie de faire des miracles , ma ca va quand meme assez bien et j'ai presque terminer mon site, mais faudrait encore que tu m'explique ou mettre le morceau de code $_GET['page'] (== 'affiche_choix')
voici ma page 1 pour te donner une bonne idée !:
<?php
$link = mysql_connect("localhost", "root", "");
mysql_select_db("sport", $link);
?>
<div id="velo"><img src="images/velo.jpg"width="40" height="30" alt="Mon Image"> <a href="index.php?page=affiche_choix&function=velo">velo</a>
<br>Vélo complet
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='velocomplet'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Cadre
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='cadre'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Guidon
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='guidon'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Selle
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='selle'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Roues
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='roues'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Groupo
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='groupo'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Pédalier
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='pedalier'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Autres
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='autresvelo'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
</div>
voici ma page 2 :
<html>
<head>
<title>resultat des annonces</title>
<link rel="stylesheet" href="cssfile/css_annonce.css">
</head>
<body>
<table align=center cellpadding=5>
</table><br><br>
<?php
include("fonction/connection_data.php");
include("fonction/mysql_func.php");
connect();
$_GET['page']== ('affiche_choix')
function velo()
{
$table="annonce";
$annonce=addslashes($annonce);
$sql="select * from $table where categorie = 'velo'";
$res2=mysql_query($sql);
echo "<table width=100% align=center border=>";
echo "<tr>";
echo "<td>ID</td>";
echo "<td>DATE</td>";
echo "<td>NOM</td>";
echo "<td>EMAIL</td>";
echo "<td>ANNONCE</td>";
echo "<td>PHOTO</td>";
echo "<td>VOIR</td>";
echo "</tr>";
while ($affiche = mysql_fetch_array($res2))
{
$id =$affiche['nbrann'];
$date=$affiche['date'];
$nom=$affiche['nom'];
$email=$affiche['email'];
$code=$affiche['code'];
$annonce= stripslashes($affiche['annonce']);
$photo=$affiche['photo'];
echo "</tr>";
echo "<td>$id</td>";
echo "<td>$date</td>";
echo "<td>$nom</td>";
echo "<td><a href=\"mailto:$email\"> $email</a></td>";
echo "<td>$annonce</td>";
if ($photo!="")
{
echo "<td><img src=\"C:\wamp\www\ybet\image_annonce/$photo\"
width=\"80\" height=\"80\"></td>";
}
else
{echo "<td><center>no photos</center></td>";}
echo"<td>";
echo"<form method=\"POST\" action=\"index.php?page=affiche_choix\">";
echo"<input name=\"id\" type=\"hidden\" value=\"$id\">";
echo"<input type=\"submit\" value=\"look\">";
echo"</form>";
echo"</td>";
echo "</tr>";
}
echo "</table>";
}
mysql_close();
?>
</body>
</html>
5 mars 2008 à 18:15
ex.page1
<div id="velo"><img src="images/velo.jpg"width="40" height="30" alt="Mon Image"> <a href="index.php?page=affiche_choix&velo()">velo</a>
<br>Vélo complet
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='velocomplet'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
<br>Cadre
<?php
$result = mysql_query("SELECT * FROM annonce where produit ='cadre'", $link);
$num_rows = mysql_num_rows($result);
echo ":$num_rows \n";
?>
page 2
appele de la function()= velo()