8791 sujets

Développement web côté serveur, CMS

Bonsoir,

Je souhaiterai changer une partie du script ci-dessous.
Je voudrai changer une partie du script (haut de page entre les pointillés) 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 multiple comparable à celui qui existe (juste en dessous dans la page)

Est-ce possible ?
Merci pour votre aide.

Eric G


<?


// 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; ?>" />&nbsp;<input type="submit" name="submit" value="<?=$lang['srchgo'];?>" />
-----------------------------------------------------------------------------------------------------------------------------
<div><p>
<i>Saisir de pr&eacute;f&eacute;rence: maison, appartement, moulin, ferme, terrain, immeuble, local commercial, location.</i>
</p>
</div>
<br /><br />

<fieldset>

<table width="100%" border="0">

<tr>

<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>

<tr>

</table>

</fieldset>

</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">
Modifié par egibault (16 Jan 2009 - 17:03)
Salut,

Utilise la balise code présente en bas du formulaire s'il te plaît, ton code présenté tel quel est illisible !
Modifié par Noix de Coco (15 Jan 2009 - 22:15)
Bonjour,

Merci Noix de Coco pour l'info...
Voici donc à nouveau le sript avec la balise code...

Eric G
[code]<?


// 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>
<i>Saisir de pr&eacute;f&eacute;rence: maison, appartement, moulin, ferme, terrain, 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>"; }?>
Modifié par egibault (16 Jan 2009 - 17:04)