Jump to content

mysql results doubling


nmrudolph

Recommended Posts

I'm working on a website that uses a database to display the employees from different states. Below is the code I'm using and everything works great, but I can't figure out why all the results are getting posted twice. I'm trying to isolate just one state so we can have a different contact page for each state. Thanks for any help! Please let me know if you need more information. (I'm attaching a screenshot of what's happening as well.)

 

 

<?
include "public/public_common.php";
//Open Database Connection
$db = open_db_connection();
$sql = "SELECT DISTINCT state_full = 'california' from users where active = 'Y' and show_on_contactus = 'Y'";
$results = mysql_query($sql, $db);
if(!mysql_num_rows($results) == FALSE)
{
        while($row = mysql_fetch_array($results, MYSQL_BOTH))
        {
           echo "<ul id=\"directors\">\n";
           $state_sql = "SELECT * from users where active = 'Y' and show_on_contactus = 'Y' and state_full = 'california' order by last_name";
	   $state_results = mysql_query($state_sql, $db);
           if(!mysql_num_rows($results) == FALSE)
           {
              while($state_row = mysql_fetch_array($state_results, MYSQL_BOTH))
              {
                 echo "<li>\n";
                 echo "   <div class=\"fl dirimg\">\n";
                 if($state_row[photo] == "")
                 {
                    echo "<img border=\"0\" width=\"61\" height=\"85\" src=\"images/exe_placeholder.jpg\" alt=\"$state_row[first_name] $state_row[last_name]\" />\n";
                 }
                 else
                 {
                    echo "<img border=\"0\" width=\"61\" height=\"85\" src=\"n2team/pictures/$state_row[photo]\" alt=\"$state_row[firstname] $state_row[last_name]\" />\n";
                 }
                 echo "   </div>\n";
                 echo "   <span class=\"fr\">$state_row[first_name] $state_row[last_name]<br />\n";
                 echo "       $state_row[title]<br />\n";
                 echo "       $state_row[city], $state_row[state]<br />\n";
                 //echo "       <a href=\"mailto:$state_row[email]\">$state_row[email]</a></span></li>\n";
              }
           }
           echo "</ul>\n";
        }
}
?>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/228123-mysql-results-doubling/
Share on other sites

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.