troubleshooting Question

only solve this with a cookie

Avatar of rgb192
rgb192Flag for United States of America asked on
PHP
11 Comments1 Solution231 ViewsLast Modified:
<?php
  // GETTING THE TITLES INTO THE ARRAY
$sql = 'SELECT id,content FROM products';
$res = mysql_query($sql) or die("FAIL: $sql <br/> " . mysql_error());
while ($row = mysql_fetch_assoc($res))
{
    $string[]=$row;
}

// SHOWING THE ARRAY OF TITLES
//print_r($string);

// COMPARISONS USING SIMILAR_TEXT() BUT SEE THE NOTES HERE BEFORE YOU USE IT!
// http://php.net/manual/en/function.similar-text.php#109507
// COMPARISONS USING SIMILAR_TEXT



foreach ($string as $x)
{
    //echo PHP_EOL . "TESTING <b>$x</b> WITH SIMILAR_TEXT()";

    // COMPARE TO THE OTHER STRINGS
    foreach ($string as $y)
    {   
        $ss = 
        similar_text(
        $x['content'], 
        $y['content'], 
        $sp);
        if (number_format($sp,0)>=75 && number_format($sp,0)<100){
          $sql="insert into similar(orig,sim,per) values('{$x['id']}','{$y['id']}',".number_format($sp,0).");";
          echo '<br>'.$sql;
        }
    }
}
?>


this program takes hours (almost a day to run) because I am comparing many large product descriptions

I read
http://php.net/manual/en/function.setcookie.php
and other php.net pages and do not understand how I can implement cookie for this script
and how I can resume the foreach loop

I am not looking for a cpu answer or to change the code or use another database or scripting language or to write to a database or write to a file

want to put a cookie so I know $x['id']
so if browser crashes I can continue comparison
ASKER CERTIFIED SOLUTION
Mark Gilbert
Senior Performance Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros