Jump to content

php/mysql code help please


paulmo

Recommended Posts

this is a series of queries, meant to echo 'echo_good' or 'echo_bad' column rows, but it's echoing 'keyword' row match instead. help please and thanks in advance.

 

$sql = "SELECT * FROM rcenter WHERE MATCH good AGAINST ('%$word%')";

$result = mysql_query($sql) or die (mysql_error ());

$n=0;

while($row = mysql_fetch_assoc($result)) {

$n++;

$sql = "SELECT * FROM rcenter WHERE MATCH keyword AGAINST ('%$word')";

$result = mysql_query($sql) or die (mysql_error ());

$sql = "SELECT * FROM rcenter WHERE keyword.id = echo_good.id AND (keyword.id LIKE '%$word%')";

$result = mysql_query($sql) or die (mysql_error ());

while($row = mysql_fetch_assoc($result)) {

$n++;

nl2br(stripslashes($row['echo_good']));

echo "<br>";

}

}

 

$anymatches=mysql_num_rows($result);

 

if ($anymatches == 0)

{

$sql = "SELECT * FROM rcenter WHERE MATCH bad AGAINST ('%$word%')";

//etc...

Link to comment
https://forums.phpfreaks.com/topic/185736-phpmysql-code-help-please/
Share on other sites

What is this

$sql = "SELECT * FROM rcenter WHERE MATCH keyword AGAINST ('%$word')";
$result = mysql_query($sql) or die (mysql_error ());

supposed to be doing..

 

Straight after you call it you are assigning $result to a whole new mysql_query..

sure, thanks:

 

user text form string ($%word%) gets matched against 'good', if match, string gets matched against 'keyword', if match, echo same row in 'echo_good' to user (keyword column row id = echo_good row id).

 

same process for match on bad (except echo echo_bad).

 

if no match against either good or bad, but match on keyword, echo message to user "please elaborate on (keyword)"

 

Archived

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

×
×
  • Create New...

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.