Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
999 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  [!?!?] Recherche Multisites avec Listbox

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[!?!?] Recherche Multisites avec Listbox

n°1579111
VirtuAiles
La passion de l'aviation
Posté le 26-06-2007 à 06:56:51  profilanswer
 

Bonjour à tous,

 

J'ai décidé de me faire un page d'accueil avec mon interface vraiment personnalisée (donc pas de services en ligne déjà faits).

 

Mon problème vient du fait qu'au nombre de moteurs de recherche que je veux y mettre, je ne peux pas mettre ces 14 champs de recherche différents...

 

Je souhaitais donc pouvoir sélectionner le moteur de recherche avec une listbox, tout simplement. Ex:
http://img452.imageshack.us/img452/7176/exlistboxsearchwh1.th.jpg
[Cliquez sur l'image]

 

Voici le code de cette section, juqu'à maintenant:

Citation :

<div id="search" align="center">
<form id="form1" name="form1" method="post" action="">
<span id="sprytextfield1">
<input name="search_zone" type="text" class="login-username" id="search_zone" size="60" />
<span class="textfieldRequiredMsg">Veuillez entrer votre recherche</span></span><span id="spryselect1">
<label>
<select name="search_select" class="searchselect" id="search_select">
<option value="google-ca" >Google Canada</option>
<option value="google-ca-fr" >Google Canada:Fr</option>
<option value="google-world" >Google World</option>
<option value="google-images" >Google Images</option>
<option value="wikipedia" >Wikipedia (Fr)</option>
<option value="youtube" >YouTube</option>
<option value="urbanfonts" >UrbanFonts</option>
<option value="dafont" >DaFont</option>
<option value="wikicommons" >Wikimedia Commons</option>
<option value="morguefile" >MorgueFile</option>
<option value="stockexchange" >Stock Exchange</option>
<option value="flickrgpl" >Flikr (GPL)</option>
<option value="stockvault" >StockVault</option>
</select>
</label>
<span class="selectRequiredMsg">Sélectionnez votre moteur de recherche.</span></span>
<input name="startsearch" type="submit" class="submit" id="startsearch" value="Chercher!" />
</form>

</div>

 

Et voici, pour compléter l'exemple, les données nécessaires à mettre avant/après le mot/phrase recherché(e)(s).

 
Citation :


("http://www.google.ca/search?q="+sSearchText)
("http://www.google.ca/search?hl=fr&q="+sSearchText+"&btnG=Rechercher&lr=lang_fr" )
("http://www.google.com/search?q="+sSearchText)
("http://images.google.com/images?q="+sSearchText)
("http://fr.wikipedia.org/wiki/Special:Search?search="+sSearchText)
("http://youtube.com/results?search_query="+sSearchText)

 


Où "sSearchText" est le texte recherché.
Quelqu'un pourrai m'orienter? Un exemple serait fort apprécié... (moi qui ai pris 15 minutes de ma vie à colorier ce code :lol: ).

 

Merci beaucoup et bonne journée,
FoxLeader

Message cité 1 fois
Message édité par VirtuAiles le 26-06-2007 à 06:57:24
mood
Publicité
Posté le 26-06-2007 à 06:56:51  profilanswer
 

n°1579120
gatsu35
Blablaté par Harko
Posté le 26-06-2007 à 08:29:30  profilanswer
 

VirtuAiles a écrit :

Bonjour à tous,

 

J'ai décidé de me faire un page d'accueil avec mon interface vraiment personnalisée (donc pas de services en ligne déjà faits).

 

Mon problème vient du fait qu'au nombre de moteurs de recherche que je veux y mettre, je ne peux pas mettre ces 14 champs de recherche différents...

 

Je souhaitais donc pouvoir sélectionner le moteur de recherche avec une listbox, tout simplement. Ex:
http://img452.imageshack.us/img452 [...] wh1.th.jpg
[Cliquez sur l'image]

 

Voici le code de cette section, juqu'à maintenant:

Citation :

<div id="search" align="center">
<form id="form1" name="form1" method="post" action="">
<span id="sprytextfield1">
<input name="search_zone" type="text" class="login-username" id="search_zone" size="60" />
<span class="textfieldRequiredMsg">Veuillez entrer votre recherche</span></span><span id="spryselect1">
<label>
<select name="search_select" class="searchselect" id="search_select">
<option value="google-ca" >Google Canada</option>
<option value="google-ca-fr" >Google Canada:Fr</option>
<option value="google-world" >Google World</option>
<option value="google-images" >Google Images</option>
<option value="wikipedia" >Wikipedia (Fr)</option>
<option value="youtube" >YouTube</option>
<option value="urbanfonts" >UrbanFonts</option>
<option value="dafont" >DaFont</option>
<option value="wikicommons" >Wikimedia Commons</option>
<option value="morguefile" >MorgueFile</option>
<option value="stockexchange" >Stock Exchange</option>
<option value="flickrgpl" >Flikr (GPL)</option>
<option value="stockvault" >StockVault</option>
</select>
</label>
<span class="selectRequiredMsg">Sélectionnez votre moteur de recherche.</span></span>
<input name="startsearch" type="submit" class="submit" id="startsearch" value="Chercher!" />
</form>

</div>

 

Et voici, pour compléter l'exemple, les données nécessaires à mettre avant/après le mot/phrase recherché(e)(s).

 
Citation :


("http://www.google.ca/search?q="+sSearchText)
("http://www.google.ca/search?hl=fr&q="+sSearchText+"&btnG=Rechercher&lr=lang_fr" )
("http://www.google.com/search?q="+sSearchText)
("http://images.google.com/images?q="+sSearchText)
("http://fr.wikipedia.org/wiki/Special:Search?search="+sSearchText)
("http://youtube.com/results?search_query="+sSearchText)

 


Où "sSearchText" est le texte recherché.
Quelqu'un pourrai m'orienter? Un exemple serait fort apprécié... (moi qui ai pris 15 minutes de ma vie à colorier ce code :lol: ).

 

Merci beaucoup et bonne journée,
FoxLeader


Surtout qu'il y a une balise exactement faite pour ça : [code][code]  [ /code][/code ]


Message édité par gatsu35 le 26-06-2007 à 08:30:10
n°1579501
VirtuAiles
La passion de l'aviation
Posté le 26-06-2007 à 17:14:24  profilanswer
 

Arg... lol. Je savais qu'elle existait! Je ne l'avait pas trouvée xD
 
J'ai fini par trouver ça: (J'utilise la bonne balise lah :D)

Code :
  1. if (isset($_POST['search_select'])&&isset($_POST['search_zone']))
  2. {
  3.     switch($_POST['search_select'])
  4.     {
  5.       case 'google-ca':
  6.          $strRecherche='http://www.google.ca/search?q='.$_POST['search_zone'];
  7.            break;
  8.        case 'google-ca-fr':
  9.           [...]
  10.        default:
  11.           //mettre le moteur par défaut
  12.     }
  13.     header("Location: ".$strRecherche);
  14. }
  15. else
  16. {
  17.     //par exemple, une redirection vers ta page de recherche
  18.     header("Location: http://www.tonsite.com" );
  19. }


 
Merci et bonne journée!

n°1579570
VirtuAiles
La passion de l'aviation
Posté le 26-06-2007 à 20:02:19  profilanswer
 

Bon... alors là, j'ai tout complété et finalisé le code mais lorsque je valide, la page se recharge et... c'est tout. Voilà donc le code de la page "search.php":

Code :
  1. <?php
  2. if (isset($_POST['search_select'])&&isset($_POST['search_zone']))
  3. {
  4.     switch($_POST['search_select'])
  5.     {
  6.        case 'google-ca':
  7.          $strRecherche='http://www.google.ca/search?q='.$_POST['search_zone'];
  8.           break;
  9.        case 'google-ca-fr':
  10.          $strRecherche='http://www.google.ca/search?hl=fr&q='.$_POST['search_zone'];
  11.           break;
  12.        case 'google-world':
  13.          $strRecherche='http://www.google.com/search?q='.$_POST['search_zone'];
  14.           break;
  15.        case 'google-images':
  16.          $strRecherche='http://images.google.com/images?q='.$_POST['search_zone'];
  17.           break;
  18.   
  19.        case 'wikipedia':
  20.          $strRecherche='http://fr.wikipedia.org/wiki/Special:Search?search='.$_POST['search_zone'];
  21.           break;
  22.        case 'youtube':
  23.          $strRecherche='http://youtube.com/results?search_query='.$_POST['search_zone'];
  24.           break;
  25.        case 'urbanfonts':
  26.          $strRecherche='http://www.urbanfonts.com/fontsearch.php?searchfont='.$_POST['search_zone'].'&showfree=Y&first=N';
  27.           break;
  28.        case 'dafont':
  29.          $strRecherche='http://www.dafont.com/search.php?psize=m&q='.$_POST['search_zone'];
  30.           break;
  31.   
  32.        case 'wikicommons':
  33.          $strRecherche='http://commons.wikimedia.org/wiki/Special:Search?search='.$_POST['search_zone'];
  34.           break;
  35.        case 'morguefile':
  36.          $strRecherche='http://www.morguefile.com/archive/index.php?search_log=true&terms='.$_POST['search_zone'];
  37.           break;
  38.        case 'stockexchange':
  39.          $strRecherche='http://www.sxc.hu/browse.phtml?f=search&txt='.$_POST['search_zone'].'&w=1&x=0&y=0';
  40.           break;
  41.        case 'flickrgpl':
  42.          $strRecherche='http://www.flickr.com/search/?q='.$_POST['search_zone'].'&l=5';
  43.           break;
  44.   
  45.        case 'stockvault':
  46.          $strRecherche='http://www.stockvault.net/search.php?search='.$_POST['search_zone'];
  47.           break;
  48.        default: 'google-ca-fr'
  49.            //mettre le moteur par défaut
  50.      }
  51.      header("Location: search.php ".$strRecherche);
  52. }
  53. else
  54. {
  55.     //par exemple, une redirection vers ta page de recherche
  56.     header("Location: http://www.foxleader.fr.nf/home" );
  57. }
  58. ?>


 
et voici le code de ma page de recherche:

Code :
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>FoxLeader's //Homepage</title>
  6. <style type="text/css">
  7. <!--
  8. body {
  9. background-image: url(images/background.png);
  10. }
  11. a{
  12. color: #333333;
  13. font-weight: bold;
  14. font-family: Geneva, Arial, Helvetica, sans-serif;
  15. font-size: 12px;
  16. }
  17. a:hover{
  18. color: #8fc400;
  19. }
  20. #mainbody {
  21. position:absolute;
  22. left:50%;
  23. top:50%;
  24. margin-left:-299px;
  25. margin-top:-154px;
  26. width:598px;
  27. height:307px;
  28. z-index:1;
  29. }
  30. #main_background {
  31. height:100%;
  32. width:100%;
  33. }
  34. #search {
  35. position:absolute;
  36. left:50%;
  37. top:50%;
  38. margin-left:-279px;
  39. margin-top:-46px;
  40. width:555px;
  41. height:60px;
  42. z-index:2;
  43. }
  44. #news {
  45. position:absolute;
  46. left:50%;
  47. top:50%;
  48. margin-left:-279px;
  49. margin-top:20px;
  50. width:557px;
  51. height:108px;
  52. z-index:3;
  53. }
  54. #date { position:absolute;
  55. left:50%;
  56. top:50%;
  57. margin-left:-280px;
  58. margin-top:-100px;
  59. width:560px;
  60. height:22px;
  61. z-index:2;
  62. }
  63. /*POUR LES CHAMPS DE LOGIN*/
  64. .login-username{
  65. background-color: #f7f7f7;
  66. border-top-color: #999999;
  67. border-right-color: #aab3b3;
  68. border-bottom-color: #d5dddd;
  69. border-left-color: #aab3b3;
  70. height:22px;
  71. }
  72. login-username{
  73. background-color: #f7f7f7;
  74. border-top-color: #999999;
  75. border-right-color: #aab3b3;
  76. border-bottom-color: #d5dddd;
  77. border-left-color: #aab3b3;
  78. height:22px;
  79. }
  80. .login-username:focus{
  81. background-color: #ffffff;
  82. border-top-color: #6ab94b;
  83. border-right-color: #94da78;
  84. border-bottom-color: #aedf9a;
  85. border-left-color: #94da78;
  86. height:22px;
  87. }
  88. input.login-username{
  89. border-top-width: 1px;
  90. border-right-width: 1px;
  91. border-bottom-width: 1px;
  92. border-left-width: 1px;
  93. border-top-style: solid;
  94. border-right-style: solid;
  95. border-bottom-style: solid;
  96. border-left-style: solid;
  97. border-top-color: #CCCCCC;
  98. border-right-color: #CCCCCC;
  99. border-bottom-color: #CCCCCC;
  100. border-left-color: #CCCCCC;
  101. width: 300px;
  102. padding-top: 2px;
  103. padding-right: 4px;
  104. padding-bottom: 0pt;
  105. padding-left: 4px;
  106. margin-top: 0pt;
  107. margin-right: 0pt;
  108. margin-bottom: 4px;
  109. margin-left: 0pt;
  110. height:22px;
  111. }
  112. /*POUR LES LISTBOX*/
  113. .searchselect:hover, searchselect:focus{
  114. border-top-color: #66dd55;
  115. border-right-color: #55bb55;
  116. border-bottom-color: #459455;
  117. border-left-color: #55bb55;
  118. background:#FFFFFF;
  119. height:22px;
  120. }
  121. .searchselect{
  122. border-top-width: 1px;
  123. border-right-width: 1px;
  124. border-bottom-width: 1px;
  125. border-left-width: 1px;
  126. border-top-style: solid;
  127. border-right-style: solid;
  128. border-bottom-style: solid;
  129. border-left-style: solid;
  130. border-top-color: #CCCCCC;
  131. border-right-color: #CCCCCC;
  132. border-bottom-color: #CCCCCC;
  133. border-left-color: #CCCCCC;
  134. background:#FFFFFF;
  135. height:22px;
  136. }
  137. /*POUR LES BUTTONS*/
  138. .submit{
  139. background-color: #fefefe;
  140. border-top-width: 3px;
  141. border-right-width: 3px;
  142. border-bottom-width: 3px;
  143. border-left-width: 3px;
  144. border-top-style: double;
  145. border-right-style: double;
  146. border-bottom-style: double;
  147. border-left-style: double;
  148. border-top-color: #c4cccc;
  149. border-right-color: #acb5b5;
  150. border-bottom-color: #6f7777;
  151. border-left-color: #acb5b5;
  152. color: #2b333c;
  153. text-align: center;
  154. height:30px;
  155. }
  156. .submit:hover, .submit:focus {
  157. border-top-width: 3px;
  158. border-right-width: 3px;
  159. border-bottom-width: 3px;
  160. border-left-width: 3px;
  161. border-top-style: double;
  162. border-right-style: double;
  163. border-bottom-style: double;
  164. border-left-style: double;
  165. border-top-color: #aedf9a;
  166. border-right-color: #94da78;
  167. border-bottom-color: #6ab94b;
  168. border-left-color: #94da78;
  169. height:30px;
  170. }
  171. -->
  172. </style>
  173. <script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
  174. <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
  175. <link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
  176. <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
  177. <style type="text/css">
  178. <!--
  179. .searchselect1 {border-top-width: 1px;
  180. border-right-width: 1px;
  181. border-bottom-width: 1px;
  182. border-left-width: 1px;
  183. border-top-style: solid;
  184. border-right-style: solid;
  185. border-bottom-style: solid;
  186. border-left-style: solid;
  187. border-top-color: #CCCCCC;
  188. border-right-color: #CCCCCC;
  189. border-bottom-color: #CCCCCC;
  190. border-left-color: #CCCCCC;
  191. background:#FFFFFF;
  192. height:22px;
  193. }
  194. -->
  195. </style>
  196. </head>
  197. <body>
  198. <div id="mainbody">
  199.   <div id="main_background" align="center"><img src="images/main.png" alt="Main Body" width="598" height="307" /></div>
  200. </div>
  201. <div id="search" align="center">
  202.   <form id="form1" name="form1" method="post" action="search.php">
  203.   <span id="sprytextfield1">
  204.   <input name="search_zone" type="text" class="login-username" id="search_zone" size="60" />
  205.   <span class="textfieldRequiredMsg">Veuillez entrer votre recherche</span></span><span id="spryselect1">
  206.       <label></label>
  207.     <span class="selectRequiredMsg">Sélectionnez votre moteur de recherche.</span></span>
  208.   <select name="search_select" class="searchselect1" id="search_select">
  209.     <option value="google-ca" >Google Canada</option>
  210.     <option value="google-ca-fr" >Google Canada:Fr</option>
  211.     <option value="google-world" >Google World</option>
  212.     <option value="google-images" >Google Images</option>
  213.     <option value="wikipedia" >Wikipedia (Fr)</option>
  214.     <option value="youtube" >YouTube</option>
  215.     <option value="urbanfonts" >UrbanFonts</option>
  216.     <option value="dafont" >DaFont</option>
  217.     <option value="wikicommons" >Wikimedia Commons</option>
  218.     <option value="morguefile" >MorgueFile</option>
  219.     <option value="stockexchange" >Stock Exchange</option>
  220.     <option value="flickrgpl" >Flikr (GPL)</option>
  221.     <option value="stockvault" >StockVault</option>
  222.   </select>
  223. <p>  <input name="startsearch" type="submit" class="submit" id="startsearch" value="Chercher!" /></p>
  224.   </form>
  225. </div>
  226. <div id="news"></div>
  227. <div id="date" align="center">
  228.   <div align="right"><a>Beauport, le lundi 25 Juin, 23:56</a></div>
  229. </div>
  230. <script type="text/javascript">
  231. <!--
  232. var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1" );
  233. var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1" );
  234. var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2" );
  235. var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2" );
  236. //-->
  237. </script>
  238. </body>
  239. </html>


 
En espérant que quelqu'un puisse m'aider à régler mon problème! (Note: testé sous EasyPHP 2 Beta)
 
Si nécessaire, vous pouvex télécharger les fichiers du framework  Spry ici: [cliquez-moi!]
 
Alors merci de votre aide à tous!
 
FoxLeader

n°1579635
Manu la Sc​ience
...la science ... pas toujours
Posté le 26-06-2007 à 22:20:32  profilanswer
 

Essaie avec ça :
 

Code :
  1. header("Location: ".$strRecherche);


 
à la place de cela :
 

Code :
  1. header("Location: search.php ".$strRecherche);


 
Tu veux afficher dans ta page la recherche sélectionnée, c'est cela...
 
Dans le code que tu mettais, tu affichais de nouveau ta page search.php...


Message édité par Manu la Science le 26-06-2007 à 22:21:02

---------------
Proverbe chinois: il vaut mieux apprendre à pêcher à un mendiant que de lui donner du poisson...
n°1579709
VirtuAiles
La passion de l'aviation
Posté le 27-06-2007 à 06:32:19  profilanswer
 

Oh non... là je crois que je devrais me pendre! J'avais deux index, l'un complet et l'autre incomplet (un .php et l'autre .html) et par défaut, c'était le .html (l'incomplet) qui s'affichait... donc ca ne fonctionnait pas!
 
Arg XD
 
Il fallait vraiment qu'il soit minuit pour m'en rendre compte...
Merci quand même de votre aide si précieuse!
 
Il ne me reste qu'à fignoler le code html ;)

n°1580149
naeh
Posté le 27-06-2007 à 22:35:23  profilanswer
 

je ne sais pas si ton truc fonctionne ou pas, mais ne faut-il pas faire un : urlencode($_POST['search_zone']) avant de le balancer ?


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  [!?!?] Recherche Multisites avec Listbox

 

Sujets relatifs
Recherche programmmeur CSSRecherche d'un associé pour la création d'une entreprise
Recherche d'un associéRecherche projet pour apprendre
listbox multiselection et formulaireRecherche dans plusieurs tables/champs en fulltext et non full text :/
je cherche à faire une listbox dynamiqueRecherche entre deux dates avec un champs datetime
[Planning] Recherche d'un projet Open SourceRecherche script chat pour invité avec modération
Plus de sujets relatifs à : [!?!?] Recherche Multisites avec Listbox


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR