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
https://forums.phpfreaks.com/topic/213497-if-else-lookup-in-mysql/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.