is that right?PHP Code:SELECT * FROM reviews WHERE instr(gamename, '$search')
Printable View
is that right?PHP Code:SELECT * FROM reviews WHERE instr(gamename, '$search')
this is how i do it:
mysql_query("SELECT * FROM book ORDER BY title ASC",$db);
its like a mini search thingy, i want it search the reviews for $search and return the results
any suggestions?
oh ok
that will check if that has $search in it right?
correct, it will check to see if what the user entered and if it is in the database, so if
$search = table
then once it goes through it's search it then will fine any game that has table in it. that is what the % means. it can have anything before it or after it but it has to contain table.
it wont work. like it wont find anything
what's the cod eyou have now?
PHP Code:$sql="SELECT * FROM reviews WHERE (gamename LIKE '%$search%') OR (review LIKE '%$search%') OR (name LIKE '%$search%') OR (describ LIKE '%$search%')";
$result = mysql_query($sql);
echo "<UL>\n";
while ($row = mysql_fetch_array($result)) {
printf("<li><a href=\"viewreview.php?id=%s&system=%s\">%s</a> - by <a href=\"../forums/profile.php?mode=viewprofile&u=%s\">%s</a> - %s</li>", $row['id'], $row['system'], $row['gamename'], $row['id'], $row['name'], $row['describ']);
}
echo "</UL><BR>\n";
like this.
PHP Code:$sql="SELECT * FROM reviews WHERE (gamename LIKE '%$search%' OR review LIKE '%$search%' OR name LIKE '%$search%' OR describ LIKE '%$search%')";
still wont work, no errors are returned
try this and see if the select statement is ok on the ouput. also it will give an error if the result is wrong. also make sure all the categories are actually in the reviews table. Also what is the form coding that the search is coming from?
PHP Code:$sql="SELECT * FROM reviews WHERE (gamename LIKE '%$search%' OR review LIKE '%$search%' OR name LIKE '%$search%' OR describ LIKE '%$search%')";
echo $sql;
$result = mysql_query($sql);
if (!$result)
{echo mysql_error($result)}
echo "<UL>\n";
while ($row = mysql_fetch_array($result)) {
printf("<li><a href=\"viewreview.php?id=%s&system=%s\">%s</a> - by <a href=\"../forums/profile.php?mode=viewprofile&u=%s\">%s</a> - %s</li>", $row['id'], $row['system'], $row['gamename'], $row['id'], $row['name'], $row['describ']);
}
echo "</UL><BR>\n";
alright i got it, thanks
i noticed it wasnt showing the SQL statement, this was the prob:
PHP Code:if($submit){ //check if submitted
...
}