Jump to content

Need help comparing variables

- - - - -

  • Please log in to reply
No replies to this topic

#1
mickey1989

mickey1989

    Newbie

  • Members
  • Pip
  • 1 posts
Hello everyone.
I am trying to compare words used in a film review (or reviews depending on how many reviews are associated with a each film). I have tried echoing what ever is in the film review array, and its pupolated. Also i have tried echoing the positive list of words, this array is also pupolated. But when the program is executed its not comparing the review words with the list i have put together. Any clues why?

<?php

$countp=0;

$countn=0;

$x=0;				// location current word being compared

$i=0;            //secondary negative word

$f=0;           //potive loop count 

$dbhost = 'localhost'; //host

$dbuser = 'root'; //username created

$conn = mysql_connect($dbhost, $dbuser)  //Coneting to database

or die('Error connecting to mysql');

$dbname = 'afra';

mysql_select_db($dbname); // database.

if (!$dbname) 

{

echo "Could not select the database.";

}

else

echo "Successfully connected to the AFRA database<br/>";

$film_ID=$_GET["film_ID"];

echo "$film_ID film id <br>";    //not usefull

//$getReview = mysql_query("SELECT review FROM review WHERE film_ID LIKE '" . $film_ID . "'");

$getReview = mysql_query("SELECT review FROM review WHERE film_ID = $film_ID");


$pos = mysql_query("SELECT * FROM pos_List ");

$neg =mysql_query("SELECT * FROM neg_List ");

$sec = mysql_query("SELECT * from sec_Neg_List ");

//$arrayNeg = mysql_fetch_array($neg);

//$arrayPos = mysql_fetch_array($pos);

//$arraySec =mysql_fetch_array($sec);


while ($arrayReview = mysql_fetch_assoc($getReview)) 

{   

	$res = explode(" ", $arrayReview['review']);

	foreach ($res as $r) 

	{ //echo "$r " ;

	     while ($arrayPos = mysql_fetch_array($pos))

		{ 

				if ($r == $arrayPos[$f]) 

					{ 

						$countp=$countp+3;	

						if(isset($r[$x-1]))

							{ 

								while ($arraySec =mysql_fetch_array($sec)) 

						      		{echo "$s";

						      			if($r[$x-1]==$arraySec[$i]) 

						      			{

											$countp=$countp-5;	

											echo "$countp";					      		

						      			}

						      		$i++;}

							} 

							$i=0;

						if(isset($r[$x-2]))

							{ 

								while ($arraySec =mysql_fetch_array($sec)) //count missing

						      		{

						      			if($r[$x-2]==$arraySec[$i]) 

						      			{

											$countp=$countp-5;	

											echo "$countp";					      		

						      		    }

						       $i++;}

							}

					$f++;}									//increment f, while loop for postive array 

		}

			  while ($arrayNeg =mysql_fetch_array($neg)) //count missing					// Ignore all this part, has not been coded yet

		{ 

				if ($r == $v) 

					{ 

						$countn=$countn+3;

						

						if(isset($r[$x-1]))

							{ 

								while ($arraySec =mysql_fetch_array($sec)) //count missing

						      		{

						      			if($r[$x-1]==$s) 

						      			{

											$countn=$countn-5;	

											echo "$countn";					      		

						      			}

						      		}

							} 

						if(isset($r[$x-2]))

							{ 

								while ($arraySec =mysql_fetch_array($sec))   //count missing

						      		{ 

						      			if($r[$x-2]==$s) 

						      			{

											$countn=$countn-5;			

											echo "$countn";					      		

						      		    }

						      		}

							}

						

						

					}	

		

		  // if review word = neg list	

					

			}//for

			

					

		} //for each word

		$x++;

	

	} //while review field has result


echo "$countp positive<br>";

echo "$countn negative";

$x=0; 

?>







1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users