|
|
|
|
Posté par
pottepei, le jeudi 12 juillet 2007 à 22:04:58<?php
$id="".@$_GET[form_id]."";//id de l'artiste
$nom="".@$_GET[form_artiste]."";
$nom_artiste="".@$_GET[urldecode(nom_artiste)]."";//pour l'en-tête des résultats si aucun résultat
$an1="".@$_GET[form_annee1]."";
$an2="".@$_GET[form_annee2]."";
$form_formats=@$_GET[form_formats];//tableau formats
if (is_Array($form_formats)) $form_formats=addslashes(urlencode(serialize($form_formats)));
$form_pays=@$_GET[form_pays];//tableau pays
if (is_Array($form_pays)) $form_pays=addslashes(urlencode(serialize($form_pays)));
if ($ref=="") $ref="".@$_GET[form_ref]."";
if ($com=="") $com="".@$_GET[form_com]."";
if ($titre=="") $titre="".@$_GET[form_titres]."";
$variables = $HTTP_GET_VARS;
$texte = "";
$texte2 = "";
if ($variables != '') {
while (list($clé, $valeur) = each($variables))
{
switch ($clé)
{ case "form_pays" :
$valeur = unserialize(urldecode(stripslashes($form_pays)));
$i=0;
while (list($num, $gr) = each ($valeur))
{
$i++;
if ($i==1) $texte .=" AND
(disco_pays.id_pays LIKE '$gr'";
if ($i>1) $texte .=" OR
disco_pays.id_pays LIKE '$gr'";
if ($gr == '') $texte='';
}
if ($texte!='') $texte .=")";//si un texte existe, ferme la parenthèse
break;
case "form_formats" :
$valeur = unserialize(urldecode(stripslashes($form_formats)));
$i=0;
while (list($num, $gr) = each ($valeur))
{
$i++;
if ($i==1) $texte2 .=" AND (";
if ($i>1) $texte2 .=" OR ";
$texte2 .="disco_formats.id_type LIKE '$gr'";
if ($gr == '') $texte2='';
}
if ($texte2!='') $texte2 .=")";//si un texte existe, ferme la parenthèse
break;
}
}
}
$query="
SELECT
disco_artistes.nom,
disco_disques.id_disque,
disco_formats.type,
disco_disques.date,
disco_pays.abrege,
disco_disques.reference,
disco_titres.titre,
disco_disques.commentaire
FROM
disco_artistes,
disco_disques,
disco_formats,
disco_pays,
disco_titres";
//query artistes
if ($nom != '') $query .="
WHERE
disco_artistes.nom LIKE '%$nom%' AND
disco_artistes.id_artiste = disco_disques.artiste";
else $query .="
WHERE
disco_artistes.id_artiste = disco_disques.artiste";
//query id
if ($id != '') $query .=" AND
disco_artistes.id_artiste = '$id'";
//query formats
if ($texte2 != '') $query .="$texte2";
$query .=" AND
disco_formats.id_type = disco_disques.format";
//query date
if ($an2 != '' && $an1 == 1) $query .=" AND
disco_disques.date LIKE '$an2'";
if ($an2 != '' && $an1 == 2) $query .=" AND
disco_disques.date > '$an2'";
if ($an2 != '' && $an1 == 3) $query .=" AND
disco_disques.date < '$an2'";
//query annee
if ($annee != '') $query .=" AND
disco_disques.date LIKE '%$annee%'";
//query pays
if ($texte != '') $query .="$texte";
$query .=" AND
disco_pays.id_pays = disco_disques.pays";
//query ref
if ($ref != '') $query .=" AND
disco_disques.reference LIKE '%$ref%'";
//query commentaire
if ($com != '') $query .=" AND
disco_disques.commentaire LIKE '%$com%'";
//query titres
if ($titre != '') $query .=" AND
disco_titres.titre LIKE '%$titre%' AND
disco_titres.id_titre = disco_disques.titre";
else $query .=" AND
disco_titres.id_titre = disco_disques.titre";
$result = mysql_query($query) or die(mysql_error());
$numrows = mysql_num_rows($result); // result of count query
$totres = $numrows;//mémo total résultats
// ************** pager **************************
include ("pager.inc.php");
// ************** end of pager **************************
if($numrows == 0) {
LAYERINTERNE();
echo "
<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<th colspan=2>".$txt_resultat." <b>".stripslashes($nom_artiste)."</b></th>
</tr>
</table>
<table class=\"Stable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td><b>".$txt_no."</b></td>
</tr>
</table></div></div>\n";
}
else
{
$query="
SELECT
disco_artistes.nom,
disco_disques.id_disque,
disco_formats.type,
disco_disques.date,
disco_pays.abrege,
disco_disques.reference,
disco_titres.titre
FROM
disco_artistes,
disco_disques,
disco_formats,
disco_pays,
disco_titres
WHERE ";
//query artistes
if ($nom != '') $query .="
disco_artistes.nom LIKE '%$nom%' AND
disco_artistes.id_artiste = disco_disques.artiste";
else $query .="
disco_artistes.id_artiste = disco_disques.artiste";
//query id
if ($id != '') $query .=" AND
disco_artistes.id_artiste = '$id'";
//query formats
if ($texte2 != '') $query .="$texte2";
$query .=" AND
disco_formats.id_type = disco_disques.format";
//query date
if ($an2 != '' && $an1 == 1) $query .=" AND
disco_disques.date LIKE '$an2'";
if ($an2 != '' && $an1 == 2) $query .=" AND
disco_disques.date > '$an2'";
if ($an2 != '' && $an1 == 3) $query .=" AND
disco_disques.date < '$an2'";
//query annee
if ($annee != '') $query .=" AND
disco_disques.date LIKE '%$annee%'";
//query pays
if ($texte != '') $query .="$texte";
$query .=" AND
disco_pays.id_pays = disco_disques.pays";
//query ref
if ($ref != '') $query .=" AND
disco_disques.reference LIKE '%$ref%'";
//query commentaire
if ($com != '') $query .=" AND
disco_disques.commentaire LIKE '%$com%'";
//query titres
if ($titre != '') $query .=" AND
disco_titres.titre LIKE '%$titre%' AND
disco_titres.id_titre = disco_disques.titre";
else $query .=" AND
disco_titres.id_titre = disco_disques.titre";
// ************* end of search *****************/
$query .= " ORDER BY disco_artistes.nom ASC, disco_disques.date ASC, disco_formats.type ASC, disco_titres.titre ASC, disco_pays.abrege ASC"; // add query ORDER
$query .= " LIMIT ".$_GET['page'].", $limit"; // add query LIMIT
$result = mysql_query($query) or die(mysql_error());
$numrows = mysql_num_rows($result);
//echo our table
echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<th width=\"32%\">".$txt_artiste."</th>\n";
echo "<th width=\"42%\">".$txt_titre."</th>\n";
echo "<th width=\"8%\">".$txt_annee."</th>\n";
echo "<th width=\"4%\">".$txt_pays."</th>\n";
echo "<th width=\"8%\">".$txt_format."</th>\n";
echo "<th width=\"6%\">".$txt_refs."</th>\n";
$i = 0;
while ($row = mysql_fetch_assoc($result))
{
// alternate color
if($i%2 == 0)
echo "<tr class=\"TRalter\" onMouseOver='this.style.background=\"#66CCFF\"' onMouseOut='this.style.background=\"#F0F0F0\"' onClick='location=\"title.php?id=".$row['id_disque']."\"'>\n";
else
echo "<tr class=\"main\" onMouseOver='this.style.background=\"#66CCFF\"' onMouseOut='this.style.background=\"white\"' onClick='location=\"title.php?id=".$row['id_disque']."\"'>\n";
echo "<td><b><font color=blue>".stripslashes($row["nom"])."</font></b></td>\n";
$row['titre']=eregi_replace("\n","\n<br>",$row['titre']);//
echo "<td><b><font color=#020F86>".$row["titre"]."</font></b></td>\n";
echo "<td><b><font color=#020F86>".$row["date"]."</font></b></td>\n";
echo "<td><b><font color=#020F86>".$row["abrege"]."</font></b></td>\n";
echo "<td><b><font color=#020F86>".$row["type"]."</font></b></td>\n";
echo "<td><b><font color=#020F86>".$row["reference"]."</font></b></td>\n";
echo "</tr>\n";
$i++;
}
echo "</table></div>\n";
mysql_free_result($result);
}
Configuration: Windows XP Internet Explorer 6.0
Bonsoir,
help ! pas de réponses, svp ? Merci d'avance |
Salut,
Franchement, si je peux, je veux bien essayer de t'aider mais là ça me gonfle grâve de devoir lire tout ça. T'as pas moyen de mettre en évidence juste ce qui te pose problème ? |
Ajout de 2 paramètres $_GET par exemple : ...&order=a&by=auteur
Puis dans la requète SQL, ORDER BY auteur ASC (Explication un peu brève, je sais) |
je n'ai pas tout lu (jai mieux a faire de mon temps, désolé :). D'ailleur, si tu as vraiment codé tout ça pour une page, c'est que ton site a un problème ^^), mais je vis déjà te donner une solution:
tu fais ta requète, tu stocke toute les donnée (je pense qu''il ne devrait pas il y en avoir plus de 15 par page) dans un tableau et tu utilise la merveilleuse fonction sort(), ou une des fonctions du même genre (ksort, asort ect) pour ce qui est du GET (comme pour ce qui est du post d'ailleur), fais très attention a ce que l'utilisateur t'envoi: bien sur il te faut échapper tes chaines, mais ce n'est pas toujours suffisant: le type et la longueurs sont deux paramètres qui rentrent en ligne de compte. tu ne peux vraiment pas nous extraire le code qui te pose problème de cette... "courante" ascii (je qualifi ainsi mes propres script un peu complexe et beaucoup trop long, mais en utilisant un terme moins poli que "courante") merci |
Bonjour à tous, et merci pour les réponses... mais hélas, toujours pas de soluce:
alors, dans tout le texte que je vous avais mis plus haut, voici, d'une part, les codes pour la définition des entêtes du tableau, et d'autre part, pour la définition des données du tableau : // ************* end of search *****************/ $query .= " ORDER BY disco_artistes.nom ASC, disco_disques.date ASC, disco_formats.type ASC, disco_titres.titre ASC, disco_pays.abrege ASC"; // add query ORDER $query .= " LIMIT ".$_GET['page'].", $limit"; // add query LIMIT $result = mysql_query($query) or die(mysql_error()); $numrows = mysql_num_rows($result); == DEFINITION DES ENTETES DU TABLEAU == //echo our table echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n"; echo "<th width=\"32%\">".$txt_artiste."</th>\n"; echo "<th width=\"42%\">".$txt_titre."</th>\n"; echo "<th width=\"8%\">".$txt_annee."</th>\n"; echo "<th width=\"4%\">".$txt_pays."</th>\n"; echo "<th width=\"8%\">".$txt_format."</th>\n"; echo "<th width=\"6%\">".$txt_refs."</th>\n"; == DEFINITION DES DONNEES DU TABLEAU == $i = 0; while ($row = mysql_fetch_assoc($result)) { // alternate color if($i%2 == 0) echo "<tr class=\"TRalter\" onMouseOver='this.style.background=\"#66CCFF\"' onMouseOut='this.style.background=\"#F0F0F0\"' onClick='location=\"title.php?id=".$row['id_disque']."\"'>\n"; else echo "<tr class=\"main\" onMouseOver='this.style.background=\"#66CCFF\"' onMouseOut='this.style.background=\"white\"' onClick='location=\"title.php?id=".$row['id_disque']."\"'>\n"; echo "<td><b><font color=blue>".stripslashes($row["nom"])."</font></b></td>\n"; $row['titre']=eregi_replace("\n","\n<br>",$row['titre']);// echo "<td><b><font color=#020F86>".$row["titre"]."</font></b></td>\n"; echo "<td><b><font color=#020F86>".$row["date"]."</font></b></td>\n"; echo "<td><b><font color=#020F86>".$row["abrege"]."</font></b></td>\n"; echo "<td><b><font color=#020F86>".$row["type"]."</font></b></td>\n"; echo "<td><b><font color=#020F86>".$row["reference"]."</font></b></td>\n"; echo "</tr>\n"; $i++; } echo "</table></div>\n"; mysql_free_result($result); FIN DE CODE ! |
| 29/10 12h46 | Trier un tableau sans utiliser la fonction sort | Perl |
| 02/08 10h08 | [del.icio.us] Exporter vos bookmarks del.icio.us | Internet |
| 12/01 09h34 | [Excel] Trier sur les lignes (horizontalement), non les colonnes | Excel |
| 06/11 19h24 | [PHP] Upload de fichiers | PHP |
| 27/03 16h03 | [PHP] Méthodes de débogage | PHP |
| 08/11 11h48 | [PHP] tri des colonnes d'un tableau | 3 |
| 21/05 13h32 | Trier par ordre croissant des numeros | 29 |
| 24/01 17h39 | Java Trier par ordre aplhabétique(compareTo) | 8 |
| 08/11 11h40 | ACCESS-Tri par ordre numerique illogique | 30 |
![]() | WAMP Server - WAMP5 (WAMP signifiant Windows Apache Mysql PHP) est une plateforme de développement Web sous Windows. Il vous permet de... | Catégorie: Serveurs Licence: Freeware/gratuit |
![]() | PHP Edit - PHPEdit est un environnement de développement intégré (IDE) sous Windows pour le langage PHP. Il offre un grand nombre de... | Catégorie: PHP Licence: Freeware/gratuit |
![]() | Trillian - Trillian est un des clients de messagerie instantanée les plus aboutis. Il est compatible avec AIM®, MSN®, ICQ®, Yahoo!®, et... | Catégorie: Messagerie instantanée Licence: Open Source |
![]() | GigaTribe - GigaTribe (ex-TribalWeb) est un logiciel de partage de fichiers Peer-to-peer (P2P) en réseau privé. GigaTribe, permet de... | Catégorie: Téléchargement Licence: Freeware/gratuit |
![]() | HP Pavilion a6441.fr-m AMD | Catégorie: Ordinateur de bureau | 699.99 € Rue du Commerce |
![]() | AMD Phenom 8650 Triple-Core | Catégorie: Processeur | 114.99 € Surcouf |
![]() | AMD Phenom 8750 Triple-Core | Catégorie: Processeur | 139.95 € Rue du Commerce |
![]() | AMD Phenom 8450 Triple-Core | Catégorie: Processeur | 99.90 € SAB Megastore |