Jump to content


Photo

need help with my search funtion


  • Please log in to reply
3 replies to this topic

#1 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 23 May 2006 - 10:08 AM

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

This is the script for the search form

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

This is the script for searchresults.php

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

#2 samshel

samshel
  • Members
  • PipPipPip
  • Advanced Member
  • 837 posts

Posted 23 May 2006 - 10:17 AM

Change your query to :


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

hth
Cheers,
SamShel
-----------------------------------------------
--: FUTURE IS LINUX :--
-----------------------------------------------

#3 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 23 May 2006 - 10:38 AM

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



#4 izzy

izzy
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 23 May 2006 - 10:53 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users