menu choix multiples

Petit nouveau ! | 2 Messages

17 janv. 2009, 18:36

Bonjour,

Je voudrai changer une partie du script soit changer un moteur de recherche par un un menu à choix multiples.
La contrainte c'est qu'il me faut reprendre le paramétrage du moteur existant et l'adapter à un menu déroulant à choix multiples comparable à celui qui existe (voir lien ci-dessous)

http://yonne-immobilier.com/index.php?a=4

Est-ce possible ?
Merci pour votre aide.

Eric G

Code : Tout sélectionner

<? // search form and results extract($config); $kw = ''; extract($_REQUEST); ?> <form method="get" name="search" action="<? echo $searchURL; ?>"> <input type="hidden" name="a" id="a" value="<? echo $_REQUEST['a']; ?>"> <strong><?=$lang['searchkey'];?>:</strong> <input type="text" name="kw" id="kw" size="45" value="<? echo $kw; ?>" /> <div><p> <b><i>Saisissez un type de bien en utilisant un des noms suggérés :<br /></b> maison, appartement, moulin, ferme, terrain constructible, immeuble, local commercial, location.</i></p></div> <td><strong><?=$lang['srchcrt4'];?>:</strong> <select name="price" id="price"><option value="0" selected="selected"><?=$lang['srchcrt7'];?></option><option value="1"><?=$lang['srchcrtprice1'];?></option><option value="2"><?=$lang['srchcrtprice2'];?></option><option value="3"><?=$lang['srchcrtprice3'];?></option><option value="4"><?=$lang['srchcrtprice4'];?></option><option value="5"><?=$lang['srchcrtprice5'];?></option><option value="6"><?=$lang['srchcrtprice6'];?></option></select></td> <td><strong><input type="submit" name="submit" value="<?=$lang['srchgo'];?>" /></td> <tr> </form> <hr size="2" style="visibility:visible; display:block;" /> <? if(isset($_REQUEST['submit']) && !empty($_REQUEST['submit'])){ // build the search query this could get messy $sql = "SELECT * FROM ".$phprealty->db."property "; if(!empty($kw)){ $sql2 .= "(title LIKE '%$kw%' OR full_desc LIKE '%$kw%') "; } if(!empty($price) && $price > 0 && $price <= 6){ // first get the correct amounts switch($price){ case 1: $psql = "price BETWEEN 0 and 50000"; break; case 2: $psql = "price BETWEEN 50000 and 100000"; break; case 3: $psql = "price BETWEEN 100000 and 200000"; break; case 4: $psql = "price BETWEEN 200000 and 500000"; break; case 5: $psql = "price BETWEEN 500000 and 750000"; break; case 6: $psql = "price >= 750000"; break; } if(!empty($sql2)){ $sql2 .= "AND ".$psql." "; }else{ $sql2 .= $psql." "; } } // query string to get num rows to set the limit $sql3 = "SELECT id FROM ".$phprealty->db."property "; if(!empty($sql2)){ $sql3 .= "WHERE ".$sql2; } if(!empty($sql2)){ $sql .= "WHERE ".$sql2; } if(!$result = $phprealty->dbQuery($sql3)){ echo $lang['nomatch']; }else{ //echo $sql3; $nums = mysql_num_rows($result); $a = mysql_num_rows($result); // include the pagination script include(INC."PaginateIt.php"); //$PaginateIt = new PaginateIt(); $PaginateIt->SetItemsPerPage(2); $PaginateIt->SetItemCount($a); $PaginateIt->SetLinksFormat( '<<', ' | ', '>>' ); $res = $phprealty->dbQuery($sql." ".$PaginateIt->GetSqlLimit()); if(mysql_num_rows($res) < 1){ echo $lang['nomatch']; }else{ // include currency converter / formater include(INC."curr_conv.class.php"); $cf = new CurrencyFormatter(); ?> <div class="SearchTitle"><?=$lang['srchrez'];?></div> <div id="listings"> <? while($res2 = mysql_fetch_array($res)){ ?> <div class="<? echo ((++$i%2==0)?'evenTR':'oddTR'); ?>" style="padding:10px;margin:10px 0px;"> <div class="imgL"> <? // lets see if there is an image for this listing if($iresult = $phprealty->getIntTableRows($fields="*", $from="prop_img", $where="p_id=".$res2['id']." AND def=1", $sort="", $dir="", $limit="1", $push=true)){ ?> <a href="<? echo $viewPropURL."&propID=".$res2['id']; ?>" title="<?=$lang['propview'];?>"><img src="<? echo $phprealty->IMGWWW."th_".$iresult[0]['fn']; ?>" border="0" /></a> <? }else{ ?> <a href="<? echo $viewPropURL."&propID=".$res2['id']; ?>" title="<?=$lang['propview'];?>"><img src="<? echo $phprealty->WWW; ?>assets/no_img.png" border="0" /></a> <? } ?> </div><!-- end img div --> <div class="infoL"> <div class="titleL"><a href="<? echo $viewPropURL."&propID=".$res2['id']; ?>" title="<?=$lang['propview'];?>"><? echo ucwords($res2['title'])." - ".$cf->formatWithSymbol($res2['price'],"USD"); if($res2['featured']==1){ ?>&nbsp;<span style="font-size:14px;font-style:oblique;"><?=$lang['realfeat'];?></span><? } ?></a></div> <div class="descL"><strong><?=$lang['city'];?>:</strong><br /><? echo ucwords($res2['city']); ?><br /> <strong><?=$lang['summ'];?>:</strong> <br /><? echo stripslashes(substr($res2['full_desc'],0,250)); ?>... <a href="<? echo $viewPropURL."&propID=".$res2['id']; ?>" title="<?=$lang['propview'];?>"><?=$lang['clickinfo'];?></a></div> </div><!-- end info div --> <div style="clear:both;">&nbsp;</div> </div> <? }// end while ?> </div> <? }// end if for while query }// end if for query }// end if for submit ?> <? if(isset($_REQUEST['submit']) && !empty($_REQUEST['submit']) && $a > 0){ ?> <div id="Plinks"> <? echo $PaginateIt->GetPageLinks()." ".$lang['page']."</div>"; }?>

Eléphant du PHP | 170 Messages

18 janv. 2009, 20:07

Bonsoir,
l'adapter à un menu déroulant à choix multiples comparable à celui qui existe
c'est à dire pouvoir choisir plusieurs types ?
( par exemple "maison" et "ferme" ? )

est-ce que c'est ce genre de formulaire ?

Code : Tout sélectionner

<form> <select name="type[]" size="5" multiple> <option>maison</option> <option>appartement</option> <option>moulin</option> <option>ferme</option> <option>terrain constructible</option> <option>immeuble</option> <option>local commercial</option> <option>location</option> </select> </form>
( on utilise les touches "Ctrl" et "Shift" pour les choix multiples )

Petit nouveau ! | 2 Messages

18 janv. 2009, 21:05

Bonsoir

Voici donc l'objet de la modification :
je voudrais transformer le moteur de recherche en un menu multi choix identique à celui qui existe pour le budget avec deux options.
1ère option:
Je sélectione un type de bien sans tenir compte du budget
2ème option:
Je sélectionne un type de bien et un budget

Merci

Eric G