Page 1 of 1

an array of problems

Posted: Wed Sep 22, 2004 2:20 pm
by nilrem
A little Background on the issue:
I have a db of a list of words which are listed in groups. I am trying to compair thoes words to some words that my users type in.

db example
Group Name -> Words
names -> bob sms david

cars -> suv barbi hotwheels

books -> are too much work

my code:

Code: Select all

$lookup=mysql_query('SELECT group, keywords FROM groups WHERE keywords!=""');
		for($t=0;$t<=mysql_num_rows($lookup);$t++)
			{
				
				$lookup3[$t]=mysql_fetch_array($lookup); 
				$group[$t]=$lookup3[$t][group];
				$dbwords[$group[$t]]=split(' ',$lookup3[$t][keywords]);
					for($a=0;$a<=count($group);$a++)
						{
							//echo $a.'<br>';
							$compair=array_intersect_assoc($dbwords[$group[$t]],$wordtofetch); //wordtofetch is defined earlyer, and is just what the user types
							
						}	
						//echo 'this url: '.$dbwords[$t].' has this in common: '.$compair[$t].' with: '.$wordtofetch[$t].'<br>';
						//echo $compair[$t].'<br>';
			}

the only thing I cannot get to work, is it to tell me what groups the matches are in. it will tell me when theres matches...

any ideas, tia nilrem[/php_man]

This should work

Posted: Wed Sep 22, 2004 3:54 pm
by Benjamin
Kevin,

Try something like this, where it pulls records by groups, just add code and get this to work and it should be fine,

Benjamin

Code: Select all

<?php

$query = "select group from groups";
$execute = mysql_query($query,$connect);

while ($groups = mysql_fetch_assoc($execute))
  {
  $query = "select keywords from groups where group='" . $groups[group] . "'";
  $execute = mysql_query($query,$connect);
  }

?>
?>