Précédent   Forum des professionnels en informatique > PHP > Langage > Formulaires
Formulaires Forum d'entraide sur les formulaires avec PHP. Avant de poster -> FAQ formulaires, Cours de formulaires et Sources de formulaires
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 24/01/2007, 01h37   #1
Membre à l'essai
 
Inscription : décembre 2003
Messages : 107
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Bas Rhin (Alsace)

Informations forums :
Inscription : décembre 2003
Messages : 107
Points : 21
Points : 21
Par défaut Formulaire de recherche et pagination

Bonsoir,

je souhaite ajouter un formulaire de recherche dans ma page (display), mais je ne sais pas trop comment faire ! car il faut gérer les paginations en même temps, un petit coup de main serait le bienvenue, merci....

voici le code.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
switch ($_GET['c']){
 
case 'display':
//formulaire de recherche ICI
?>
 
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>?r=<?php echo $r; ?>&amp;ru=<?php echo $ru; ?>&amp;c=display">
	<input type="text" name="alpha" size="20" value="<?php if (!empty($_POST["alpha"])) {echo htmlspecialchars($_POST["alpha"],ENT_QUOTES); } ?>" />
	<input type="image" name="envoyer" src="images/valider.gif" alt="valider" />
	</form>
<?php
	$parpage = 30;
	if ( !isset($_GET['p']) ) {
	$debut= 0;
	$p = 1;
	$r=$_GET['r'];
	$c=$_GET['c'];
	$alpha=$_GET['alpha'];
	}
	else {
	$debut = ($_GET['p'] * $parpage) - $parpage;
	$p=$_GET['p'];
	$r=$_GET['r'];
	$c=$_GET['c'];
	$alpha=$_GET['alpha'];
	}
	$requeteSQLP="SELECT * FROM links WHERE titre LIKE '$alpha' ORDER BY titre ASC LIMIT $debut,$parpage";
	$resultSQLP=mysql_query($requeteSQLP);
	$nb_resultats = mysql_num_rows($resultSQLP);
	$requeteSQL="SELECT * FROM links WHERE titre LIKE '$alpha' ORDER BY titre ASC";
	$resultSQL=mysql_query($requeteSQL);
	$total_resultats = mysql_num_rows($resultSQL);
	require("include/pagination.php");
	?>
	<form action="<?php echo $_SERVER["PHP_SELF"]; ?>?r=<?php echo $r; ?>&amp;ru=<?php echo $ru; ?>&amp;c=deletechecktmp" method="post">
	<table summary="">
	<tr>
	<th>update/delete</th>
	<th>ID</th>
	<th>titre</th>
	<th>url</th>
	<th>description</th>
	</tr>
	<?php
	$i = 0;
	while ($resultat = mysql_fetch_array($resultSQLP))
	{ ?>	
	<tr class="ligne<?php echo ($i % 2); ?>">
	<td><input type="checkbox" name="id[]" value="<?php echo $resultat['id_links']; ?>" />
	<a href="<?php echo $_SERVER["PHP_SELF"]; ?>?r=<?php echo $r; ?>&amp;ru=<?php echo $ru; ?>&amp;c=update&amp;id=<?php echo $resultat['id_links']; ?>" title="modifié">updtae</a>
	<a href="<?php echo $_SERVER["PHP_SELF"]; ?>?r=<?php echo $r; ?>&amp;ru=<?php echo $ru; ?>&amp;c=deletetmp&amp;id=<?php echo $resultat['id_links']; ?>" title="supprimé">delete</a>
	</td>
	<td><?php echo $resultat['id_links']; ?></td>
	<td><?php echo stripslashes($resultat['links']); ?></td>
	<td><?php echo stripslashes($resultat['url']); ?></td>
	<td><?php echo stripslashes($resultat['description']); ?></td>
	</tr>
	<?php
	$i++;
	}
	?>
	</table>
	<input type="image" name="delete" src="media/icons/cross.png" value="delete" />supprimer les cases cochés
	</form>
	<?php require("include/pagination.php");
break;
jarod71 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/01/2007, 08h24   #2
Membre confirmé
 
Avatar de Amine_sas
 
Étudiant
Inscription : juin 2005
Messages : 245
Détails du profil
Informations personnelles :
Âge : 27
Localisation : France, Paris (Île de France)

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2005
Messages : 245
Points : 295
Points : 295
Envoyer un message via Yahoo à Amine_sas Envoyer un message via Skype™ à Amine_sas
Bonjour
Crée un fichier séparé (exp: mon_formulaire.php).
et dans le code ajoute:
Code :
1
2
3
4
5
6
7
<?php
switch ($_GET['c']){
 
case 'display':
include("mon_formulaire.php");
break;
?>
Amine_sas est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 00h36.


 
 
 
 
Partenaires

Hébergement Web