php operator question

Posted on 2011-10-15
Last Modified: 2012-05-12
I do a mysql query on DATABASE1 and get echo a business name (bizName)  with the code below.

Now if I receive a second database which is called DATABASE2 - I do exactly the same query to echo a business name on DATABASE2.

What I would like to do is NOT to echo a business name when I query DATABASE2 if the business name string is exactly the same string as in DATABASE1.

Thanks for help!
<table style="width:550px ;line-height:20px">

$result1 = mysql_query("SELECT bizID,bizName,bizAddr FROM DATABASE1 WHERE bizState='$bizState'GROUP by bizName LIMIT 12");  

$bizID = $r['bizID'];
$bizName = $r['bizName'];
$bizAddr = $r['bizAddr'];

 	$bizCityLink = str_replace(" ","-",$bizCity);
	$bizCityLink = strtolower($bizCityLink);
	$bizStateLink = strtolower($bizState);
	$bizNamev = replaceForLink($bizName);

	$bizNameLink = replaceForText($bizName);

                                        echo "<tr>";
echo '<td><a href="'. $urlPrefix . $bizStateLink . '/' . $bizCityLink . '/' . $bizID . '-' .  $bizNamev . '.html">' . $bizNameLink .'</a><br>

                        echo "</tr>";
                        $counter = 0;


Open in new window

Question by:seopti
    LVL 33

    Expert Comment

    Where/when are you querying DATABASE2?

    If you only want to return values that aren't in DATABASE1 then you could do it with a query.
    LVL 107

    Accepted Solution

    I doubt if I can write the code for you but I can suggest a design strategy.  On line 10, you assign a value to $bizName.  Put this value into an array like this:

    $allbizNames[] = $bizName;

    Then after you execute your second query and extract the $bizName from the rows, test it like this:

    if (in_array($bizName, $allbizNames)) /* SKIP PRINTING */

    Man page here:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now