[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

php operator question

Posted on 2011-10-15
2
Medium Priority
?
170 Views
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">

<?php
 $counter=0;
$result1 = mysql_query("SELECT bizID,bizName,bizAddr FROM DATABASE1 WHERE bizState='$bizState'GROUP by bizName LIMIT 12");  
 while($r=mysql_fetch_array($result1))
{

$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);

  if($counter==0)
                  {
                                        echo "<tr>";
										 }
echo '<td><a href="'. $urlPrefix . $bizStateLink . '/' . $bizCityLink . '/' . $bizID . '-' .  $bizNamev . '.html">' . $bizNameLink .'</a><br>



			</td>';
 if($counter==1)
                  {
                        echo "</tr>";
                        $counter = 0;
                        continue;
                  }
                                  $counter++;
            }

            ?>
			</table>

Open in new window

0
Comment
Question by:seopti
2 Comments
 
LVL 36

Expert Comment

by:Norie
ID: 36974600
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.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 36974618
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:
http://php.net/manual/en/function.in-array.php
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.
Suggested Courses

591 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