Forum Moderators: open

Message Too Old, No Replies

simple search algorithm

         

kkonline

4:28 am on Mar 9, 2008 (gmt 0)

10+ Year Member



Hi I am in process of making a search script. When i write the below code it doesn't give any result. also it doesn't enter the while loop. When i write the query in sql, no results are displayed.

What could be the reason?


if (content_type($section_id,$fetched_section)==0)//type=text
{
$sqlcontent = "SELECT * FROM $fetched_section WHERE `trusted` = 1 AND title LIKE '".$query."%' And content LIKE '".$query."%' ORDER BY `title` ASC LIMIT 0, 10";

$resultcontent = mysql_query($sqlcontent) or die(mysql_error());

while($row = mysql_fetch_array($resultcontent)){
echo 'we are here';
echo $row['id'];

echo $row['content'];
}
}
else
echo 'non text';

undream2

11:45 am on Mar 9, 2008 (gmt 0)

10+ Year Member



not too sure.. The script looks similiar in mysql functions as my search.

Why don't you try this. Since, you are using fetch_array.

while($row = mysql_fetch_array($resultcontent)){

$id = $row["id"];
$content = $row["content"];

echo ".$id.";
echo ".$content.";

don't know, if it will work. Might as well try.

undream2

11:48 am on Mar 9, 2008 (gmt 0)

10+ Year Member



Well, to be honest I don't know, if quotes should be around the .$vars.

This is how I have it on my search..
echo "<font face=verdana size=3><a href=".$link.">".$title."</a></font><br>";