Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Why Echo does not work on php variable the second and third time?

$
0
0

The variable $q_words[$loop_count-1]  is shown in the top besides Did you mean? but it fails to come up inside of the hyperlink. Any ideas to why?

 

 

 

<?php
if ($_POST['query'])


{
    $query = ($_POST['query']);
    $q_words = explode (" ", $query); 
    $loop_count = 0;
    $q_count = count(q_words);
    $s_count = 0;
    $ss_count = 0;
    while ($loop_count <= $q_count )
    {
        $query = 'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/'.$q_words[$loop_count].'?key=135a6187-af83-4e85-85c1-1a28db11d5da';
        $xml = new SimpleXMLIterator(file_get_contents($query));
        
        foreach ($xml -> suggestion as $suggestion[$s_count])
        {
            $s_count++;
        }
        if ($s_count > 1)
        {     
            echo ('<h4>Did you mean ....? '.$q_words[$loop_count-1].'</h4>');
            while ($ss_count <=$s_count)
            {
            echo '<a href = "AllinOneMonstaaa.php?query='.$q_words[loop_count-1].' '.$suggestion[$ss_count].'">'.$q_words[loop_count-1].' '.$suggestion[$ss_count].'</a><br>';
            $ss_count++;
            }
        
        }
     $loop_count++;   
    }
}

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles