Dat begrijp ik maar de site is een aanéénschakeling van php pagina's dus ikdacht dat het makkelijker is om je naar de site zelf te verwijzen. maar hieronder vind je de code van de desbetreffende pagina.
Deze pagina maakt de linker en de rechter div aan. Met in de linker div de weergave van de volledige inhoud van de data base. In de rechter div roep ik de zoekfunctie op. Met deze zoekfunctie wil ik dus de resultaten in de linker div kunnen filteren op - Plaats, Postcode of Zoekwoord.
Code:
<div class="content" style="position:relative; float:left; width:960px; height:auto; margin:0px auto 45px auto;">
<div style="width:auto; height:45px; position:relative; float:right; right:100px; top:-45px; padding-left:20px; padding-right:20px; background-color:#d2c8aa; border-left:1px solid #FFFFFF; border-top:1px solid #FFFFFF; border-right:1px solid #FFFFFF;">
<div class="headimg" style="border-right:solid 1px #ff9b00; height:50px; width:60px;">
<img src="./img/immoimg/pictorenov.png" alt="Maisons et Propriétés à Rénover" width="50px" height="50px;" title="Maisons et Propriétés à Rénover en Dordogne" />
</div>
<div class="headtext"><center><h1 style="color:#333333; padding-top:8px;">Propriétés à Rénover</h1></center>
</div>
</div>
<br class="clearfloat" />
<div class="immoobjecten" style="width:550px; margin:-35px auto 20px auto; float:left; left:0px;">
<table cellspacing="5" style="margin:auto 0 auto 0">
<?
$query = mysql_query("SELECT * FROM immobilier WHERE renovation='oui'");
while ($result = (mysql_fetch_array($query))){
$result["date"] = date("d-m-Y", strtotime($result["date"]));
$result["title"]= substr($result["title"],0,150);
$result["text"]= substr($result["text"],0,250);
$result["text"] = str_replace("``", "\"",$result["text"]);
$result["text"] = strip_tags($result["text"]); ?>
<tr>
<td>
<table width="100%" style="border:1px dashed #999999;">
<tr bgcolor="#f0ead7">
<td width="auto" rowspan="3" valign="top">
<? if ($result["img1"] != 'noimage.gif') { ?><img width="150" src="http://
www.immocentre-dordogne.com/immobilier/<?= $result["id"];?>/<?= $result["img1"];?>" /><? } ?>
</td>
<td height="20" style="color:#FFFFFF; padding-left:5px; background:#92875F;">
<center><h2><?= $result["title"];?></h2></center>
</td>
</tr>
<tr>
<td class="text" align="left" valign="top" bgcolor="#d2c8aa" style="padding-left:5px;">
<span class="text"><?= $result["text"];?>...
<a style="color:#ff9b00" href='index.php?page=immodetails&id=<?= $result["id"];?>'>Details</a></span>
</td>
</tr>
<tr>
<td height="10" style="color:#333333; padding-right:5px; background:#92875F; text-align:right;">
Prix: <?= $result["prix"];?> Euros
</td>
</tr>
</table>
<? } ?>
</td>
</tr>
</table>
</div>
<div class="immoobjecten" style="width:400px; margin:-35px auto 20px auto; float:left; left:20px;">
<?php include "search-immo.php";?>
</div>
**************
CODE SEARCH-IMMO.PHP
<div style="width:350px; height:250px; border:1px #FFFFFF solid; margin:20px auto 10px auto; position:relative; float:left;">
<h2>Search</h2>
<form name="search" method="post" action="<?=$PHP_SELF?>">
Seach for: <input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="ville">Plaats</option>
<Option VALUE="cp">Postcode</option>
<Option VALUE="text">Zoekwoord</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
<?
//This is only displayed if they have submitted the form
if ($searching =="yes")
{
echo "<h2>Resultaten</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>U moet een zoekterm invullen !";
exit;
}
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM immobilier WHERE upper($field) LIKE'%$find%'");
//And we display the results
while($result = mysql_fetch_array( $data ))
{
echo $result['ville'];
echo " ";
echo $result['cp'];
echo "<br>";
echo $result['text'];
echo "<br>";
echo "<br>";
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, wij hebben geen resultaten kunnen vinden.<br><br>";
}
//And we remind them what they searched for
echo "<b>U heeft gezocht op :</b> " .$find;
}
?>
</div>
[size=xsmall]
Toevoeging op 03/02/2013 15:07:10:[/size]
Ik moet dus een manier vinden om de Id's uit de table "immobilier" van mijn mysql database weer te geven in de linker div geselecteerd op de resultaten uit de array $data welke wordt gegenereerd door de zoekfunctie. Maar hoe doe ik dat???