Validate iTunes links I'm working on this code and I can't find a better way to improve this code, can anyone improve it more? My PHP is pretty bad, this is the best I could do.

The code checks if iTunes link exists in the database if not search it on iTunes with API and if successfully found a link in itunes api it will be added in the database. If iTunes search is empty and iTunes row in the database is empty a string 'gol' will be saved in the MySQL and based on this string it will be rechecked in the future because Itunes has a 20 searches per minute limit. 
Hope i explained what is the code supposed to do.

if (empty($video['itunes'])) {
    //if mysql row $video['itunes'] is empty check the function ituneslink
    $itunecheck = ituneslink($mystrings);
    //ituneslink is a function that searches the itunes library for Movies/Music
    if (empty($itunecheck)) {
    //if ituneslink function is empty trigger the empty string itunesgol and
        $itunesgol = '';
        $smarty-&gt;assign('itunesgol', $itunesgol);
        itunes_add_item("gol", $video['uniq_id']);
    //add in mysql 'gol' that the itunescheck didn't found nothing on itunes 
    //search api, this will be useful for future rechecks
    }
} elseif($video['itunes'] != "gol") {
    // if row itunes is not 'gol' it means that itunescheck got the itunes link 
    //and succesfully added in database
    $itunecheck = $video['itunes'];
} else {
    $itunesgol = '';
    $smarty-&gt;assign('itunesgol', $itunesgol);
}


if ($video['itunes'] == 'gol') {
    //because itunes seach api has a limit of 20 req per minute i had to recheck
    //for this string if available because maybe the first search got 403 
    //fobiden because of to many queries
    $itunecheck = ituneslink($mystrings);
    itunes_add_item($itunecheck, $video['uniq_id']);
}

if (empty($video['itunes']) &amp;&amp; !empty($itunecheck) &amp;&amp; $video['itunes'] != "gol") {

    //NOW here i check if itunes is empty and itunescheck not empty and row 
    //itunes not 'gol'. If all of them comply it will be added in the database
    itunes_add_item($itunecheck, $video['uniq_id']);
}


The code works well, what i want is: to improve it, to shorten the code, to make it smoother, faster, it looks too messy
if (empty($video['itunes']) &amp;&amp; !empty($itunecheck) &amp;&amp; $video['itunes'] != "gol") {



If $video['itunes'] is empty, then you already know that it does not equal "gol".  So you could just say 

if (empty($video['itunes']) &amp;&amp; !empty($itunecheck)) {


And you would get the same effect.  

Similarly, we could rewrite the whole thing as 

if (empty($video['itunes'])) {
    //if mysql row $video['itunes'] is empty check the function ituneslink
    $itunecheck = ituneslink($mystrings);
    //ituneslink is a function that searches the itunes library for Movies/Music
    if (empty($itunecheck)) {
        //if ituneslink function is empty trigger the empty string itunesgol and
        $itunesgol = '';
        $smarty-&gt;assign('itunesgol', $itunesgol);
        itunes_add_item('gol', $video['uniq_id']);
        //add in mysql 'gol' that the itunescheck didn't find anything on itunes 
        //search api, this will be useful for future rechecks
    } else {
        //NOW here I check if itunes is empty and itunescheck not empty and row 
        //itunes not 'gol'. If all of them comply it will be added in the database
        itunes_add_item($itunecheck, $video['uniq_id']);
    }
} elseif($video['itunes'] == 'gol') {
    $itunesgol = '';
    $smarty-&gt;assign('itunesgol', $itunesgol);
    //because itunes search api has a limit of 20 req per minute I had to recheck
    //for this string if available because maybe the first search got 403 
    //forbidden because of too many queries
    $itunecheck = ituneslink($mystrings);
    itunes_add_item($itunecheck, $video['uniq_id']);
} else {
    // if row itunes is not 'gol' it means that itunescheck got the itunes link 
    //and successfully added in database
    $itunecheck = $video['itunes'];
}


This gets rid of the redundant if statements, adding to the original blocks instead.  

Or 

if (empty($video['itunes']) || ($video['itunes'] == 'gol')) {
    // if no cached result, or cached as `gol`
    // fetch new results from iTunes
    $itunecheck = ituneslink($mystrings);
    if (empty($itunecheck)) {
        $itunesgol = '';
        $smarty-&gt;assign('itunesgol', $itunesgol);
        itunes_add_item('gol', $video['uniq_id']);
    } else {
        itunes_add_item($itunecheck, $video['uniq_id']);
    }
} else {
    // otherwise use cached result
    $itunecheck = $video['itunes'];
}


This changes the behavior slightly.  It doesn't assume that a second iTunes search will always return results.  Instead, it treats a cached failure the same as no result in cache.  

But if we do that, we can go ahead and just say 

if (empty($video['itunes'])) {
    // if no cached result
    // fetch new results from iTunes
    $itunecheck = ituneslink($mystrings);
    if (empty($itunecheck)) {
        $itunesgol = '';
        $smarty-&gt;assign('itunesgol', $itunesgol);
    } else {
        itunes_add_item($itunecheck, $video['uniq_id']);
    }
} else {
    // otherwise use cached result
    $itunecheck = $video['itunes'];
}


This removes the concept of caching failures.  Instead, we'll just generate a cache miss next time.  

You could also go the other direction and add more complexity such that you sometimes redo a 'gol' and sometimes don't.  Or whatever.  But as things are written, there doesn't seem to be any reason to have two cases with mostly the same behavior.  

It is of course possible that I'm missing something.  You don't include definitions for ituneslink, itunes_add_item, and $smarty-&gt;assign, so there could be special stuff happening there.  Or prior to this code in setting $video['itunes'].  Or after this code that uses $itunesgol or $itunecheck.  But from what I see of this code, this seems to do mostly the same thing as the original.