twittoris Posted September 15, 2010 Share Posted September 15, 2010 I am running a search for a specific link on my site in order to make a big change but some of my entries are a little malformed. How do I make this script go to the next record if no match is found. Here are the two pieces of code: $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ echo $row['name']; echo "<br />"; //After the page is loaded search for specified links for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $url = $href->getAttribute('href'); $purl = substr($url, 30,300); //Here I would like to continue the while loop //Maybe if i could find the value "No entities were found" it would escape it just as well? At the end of the code I would like to continue the while loop if i could find the value "No entities were found" on the page that is missing the link I need. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
love_bug Posted September 15, 2010 Share Posted September 15, 2010 he he he he Quote Link to comment Share on other sites More sharing options...
twittoris Posted September 15, 2010 Author Share Posted September 15, 2010 I want it do escape the loop if it is not found like below: However this is not working. If ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $url = $href->getAttribute('href'); $purl = substr($url, 30,300); echo '<p>Found:<br />' . $purl. '<br />Retrieving Additional Information... '; } else { echo '<p>No Match Found For:<br />'.$row['name'].'<br />'; } It never gets to the else statement even if no link is found. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.