Jump to content

If .... Else lookup in mySQL


twittoris

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.