Eléphanteau du PHP |
38 Messages
07 déc. 2010, 02:06
<?php
session_start();
?>
<HMTL>
<p>
Tapez le nom ou une partie du nom
</p>
<form action="" method="post">
<p>
<input type="text" name="nom" />
<input type="submit" value="Valider" />
</p>
</form>
</HTML>
<?php
$table=$_SESSION['newrech'];
$nom=$_POST['nom'];
if (isset($_GET['ajoutid']))
{
$id2 = $_GET['ajoutid'];
}
mysql_connect("localhost", "root", "root") or die (mysql_error ());
mysql_select_db("test")or die (mysql_error ());
// La c'est ma recherche dans la base
$reponse = mysql_query("SELECT * FROM licences JOIN clubs ON licences.club = clubs.club WHERE nom LIKE '%".$nom."%'");
// On affiche chaque entrée une à une
If ($nom == NULL) {
echo 'veuillez taper un nom</br>';
}
else {
while($data=mysql_fetch_array($reponse))
echo '<a href="?'.SID.'&id='.$table.'&ajoutid='.$data['IUF'].'">'.$data['Nom'].' '.$data['Prenom'].'</a> '.$data['Naissance'].' '.$data['usuelclub'].'<br />';
}
$id2 = $_GET['ajoutid'];
$id3 = $_GET['id'];
mysql_query("INSERT INTO $id3 SELECT * FROM licences WHERE IUF LIKE '$id2'");
echo '<a href="resultats.php?table='.$table.'" target="resultats">Cliquez ici pour afficher les resultats</a></br>';
echo '<a href="export2.php?table='.$table.'" target="blank_">exporter les resultats</a>';
?>
Voilà un exemple c'est pas très propre .... c'est fouillis mais ça marche ...
je vais dans un deuxième essayer d'apprendre à optimiser tout ça ...