Jump to content

Archived

This topic is now archived and is closed to further replies.

izzy

need help with my search funtion

Recommended Posts

Hi,

I am making a search function for my site which now is being built in php5.
(I think) I'm doing something wrong in the script for the search results searchresult.php.

I've lookt all over the NET to find my answer but i just don't get it.

Can someone please help me solve my problem and explain what i am doing wrong.
Here are my wonderfull creations...

[b]This is the script for the search form[/b]

<form action="searchresults.php" method="post">
<table>
<tr>
<td width="120">Search:</td>
<td>
<input type="text" name="searchall" size="45">
</td>
</tr>
<tr>
<td>
<input type="hidden" name="searchresults" value="searchresults.php">
<input type="submit" name="submit" value="search"
</td>
</tr>
<table>
</form>

[b]This is the script for searchresults.php[/b]

//Een verbinding met de database maken
include("../systeem/connect.inc.php");
$search_SQL="SELECT * FROM huis WHERE searchall LIKE '%searchresults%' ORDER BY naam" or die("kan geen gegevens vinden");

$search_result=mysql_query($search_SQL);
$result=mysql_fetch_array($search_result);
//afbeelding voorbereiden
$img="";
if($result['fotopath']) $img="<img width=150 height=150 src='../planeshop/catalogus/afbeeldingen/" . $result['fotopath'] . "'>";


?>

<table width="410" border="0">
<tr>

<span><strong><?php echo $result['naam']?></strong></span>
<td width="350">
<table width="210" border="0">
<tr>
<td width="100">prijs: </td>
<td>
<span><?php echo $result['prijs']?></span>
</td>
</tr>
<tr>
<td>regio: </td>
<td>
<span><?php echo $result['regio']?></span>
</td>
</tr>
<tr>
<td>plaats: </td>
<td>
<span><?php echo $result['plaats']?></span>
</td>
</tr>
<tr>
<td>Opp. huis: </td>
<td>
<span><?php echo $result['opphuis']?></span>
</td>
</tr>
<tr>
<td>Opp. perceel: </td>
<td>
<span><?php echo $result['oppperceel']?></span>
</td>
</tr>
<tr>
<td>inhoud: </td>
<td>
<span><?php echo $result['inhoud']?></span>
</td>
</tr>
<tr>
<td>omschr.: </td>
<td>
<span><?php echo $result['omschr']?></span>
</td>
</tr>
</table>
<td width="200">
<span><?php echo $img?></span>
</td>
</table>
<p><p></p></p>
<?php

mysql_close
?>

Share this post


Link to post
Share on other sites
Change your query to :


$search_SQL="SELECT * FROM huis WHERE searchall LIKE '%".$_POST['searchresults']."%' ORDER BY naam" or die("kan geen gegevens vinden");

hth

Share this post


Link to post
Share on other sites
I did and this appears.
this message is the same as what i got before.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\makelaar\search\searchresults.php on line 8
prijs:
regio:
plaats:
Opp. huis:
Opp. perceel:
inhoud:
omschr.:

Share this post


Link to post
Share on other sites
Ive got it!!!
Igot my database field and my $_POST field mixed up.
I swithed them and voila... it works.
Somehow you got me lokking in the right direction.

THANX

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.