Jump to content

Not excluding from an array


dexterpound

Recommended Posts


<?php
global $IN;
$a = "2013_pros_list";
$b = "2013_pros";
$c = "ska_points_tour_2013";
$key = "team_id";
$type = "pro";

$query = "SELECT * FROM $a 
            LEFT JOIN $c ON ($c.$key=$a.$key) 
            LEFT JOIN $b ON ($b.$key=$a.$key) 
            ORDER BY `total` DESC LIMIT 75";



  
 
$exclude_list = array("LADIES","JUNIOR","SENIOR");
  if(!in_array($str, $exclude_list)){

  
  $place = "";        
  $result = mysql_query($query) or die(mysql_error());
  while($row = mysql_fetch_array($result)){  
  $place++; 
  
  $str = $row['type'];

The function of the page is to pull data from a sql DB in which the table has Fishing Team Names with a unique Number associated with the team.

The catch:

Each team has a unique number attached to it.

This team can fish 4 different categories:

LADIES, PRO, SENIOR, and JUNIOR.

We need to show just the PRO on this page.

So lets say Big Joe Fisher is the Team Name and the number is 1234-0, and Big Joe Fisher fishes as a Senior in on event and a Pro in another we seam to get him showing up two times on the page even though the $exclude_list = array is asking to "exclude" Seniors. (and Ladies and Junior types) from the database  "ska_points_tour_2013"

 

Although the "key" is the "team_id" we are looking to just pull all the "PRO" "type" and exclude the other categories.

 

Can you dig it?

 

Thanks for the help.

Link to comment
Share on other sites

Lot's of problems.  It's not complete code, it doesn't make much sense and your primary goal (excluding), you're doing before the query and before you define $str.

 

Why not just do something like this in the query:

WHERE table_name.type NOT IN ('LADIES','JUNIOR','SENIOR')

Or simpler if you know you only want PRO:

WHERE table_name.type = 'PRO'
Link to comment
Share on other sites

{assign_variable:template_path="shared"}
{embed="shared/.global_header"}
    <title>Yamaha Professional Kingfish Tour Championship | Biloxi, Mississippi | 

November 4-6, 2013</title>
    <meta name="Description" content="Based in St Augustine, Florida. Contains 

membership benefits and policies, history, mercury tournament trail, yamaha pro tour, 

news, tournament results and corporate partners.">
    <link rel="stylesheet" type="text/css" href="/shared/reset.css" media="screen" />
    <link href='http://fonts.googleapis.com/css?family=Open

+Sans:300,300italic,400,400italic,600,600italic,700,700italic,800,800italic' 

rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="/shared/text.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="/shared/960.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="/shared/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="/pro12/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="/shared/nav.css" />
    <link rel="stylesheet" type="text/css" href="/pro13/nav.css" />


<script type="text/javascript" src="/shared/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="/shared/jquery-ui.js"></script>
    <script type="text/javascript" src="/shared/jquery-fluid16.js"></script>
    <script type="text/javascript" src="/shared/jquery-tools.js"></script>
    <script type="text/javascript" src="/shared/jquery-cycle.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
      $('.slideshow').cycle({
        fx: 'fade'
      });
      });
    </script>
    <script type="text/javascript">
      $(document).ready(function() {
      $('.ruggedShark').cycle({
        fx: 'fade'
      });
      });
    </script>
    
    
 <script type="text/javascript">
      $(document).ready(function() {
      $('.slideshow2').cycle({
        fx: 'scrollDown' 
      });
      });
    </script>
    <script type="text/javascript">
      $('#shuffle_featured').cycle({ 
      fx: 'custom', 
      sync: 0, 
      pause: 1,
      pager:  '#nav', 
      pagerAnchorBuilder: function(idx, slide) { 
        return '#nav li:eq(' + idx + ') a'; 
      },
      cssBefore: {  
        top:  0, 
        left: 400, 
        display: 'block' 
      }, 
      animIn:  { 
        left: 0 
      }, 
      animOut: {  
        top: 400 
      }, 
      delay: -1000 
      });
    </script>
    <script type="text/javascript">
      $(document).ready(function() {
      $("#chained").scrollable().navigator().mousewheel()});
    </script>
    <script type="text/javascript">
      $(document).ready(function() {
      $("img[rel]").overlay();
      });
    </script>
  <style>
  body,p  {font-size:15px;}
div.teamName {font-size:2.25em; color:#bcad01;}
div.totalPoints {font-size:2.25em; color:#bcad01; float:right;}
.leftCol, .rightCol, .bio, .types {padding:5px;}
.leftCol, .rightCol {width:45%;}
.leftCol {float:left;}
.rightCol {float:right;}
b {color:#168bcb;}
.bio h2 {color:#cccccc; text-align:center; }
.rounded {
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
}
</style>    
    
    
</head>


<body>    

<div class="container_16" id="leaderboard">
{embed="pro13/.global_header"}



<div class="clear"></div> 
<div class="grid_16" style="border-bottom:1px solid #fff; text-align:center;"><span 

style="font-size:2em;">Professional Kingfish Tour Championship</span><br> 
</div>
<div class="clear"></div>
<div class="grid_16"><img src="/resources/2012/pros/ChampionshipWebsite13.png"></div>
<div class="grid_8" style="text-align:center;">

</div>
<div class="clear"></div>



<?php
global $IN;
$a = "2013_pros_list";
$b = "2013_pros";
$c = "ska_points_tour_2013";
$key = "team_id";
$type = "pro";

$query = "SELECT * FROM $a 
            LEFT JOIN $c ON ($c.$key=$a.$key) 
            LEFT JOIN $b ON ($b.$key=$a.$key) 
            ORDER BY `total` DESC LIMIT 75";



  
 
$exclude_list = array("LADIES","JUNIOR","SENIOR");
  if(!in_array($str, $exclude_list)){

  
  $place = "";        
  $result = mysql_query($query) or die(mysql_error());
  while($row = mysql_fetch_array($result)){  
  $place++; 
  
  $str = $row['type'];
  
           
  
  if ($row['alternate_layout'] == "0") {
    $minHeight = "725";
  } elseif ($row['alternate_layout'] == "1") {
    $minHeight = "600";
    echo "<div class=\"clear\"></div><hr>";
  } elseif ($row['alternate_layout'] == "2") {
    $minHeight = "500";
    echo "<div class=\"clear\"></div><hr>";
  }
  ?>
    <div class="grid_12 prefix_2" style="min-height:<?php echo $minHeight; ?>px;">

      <div class="teamName">
        <?php echo $place; ?>. <b>
        <?php 
        if ($row['teamname']){
          echo $row['teamname'];
        } else {
          echo $row['prefix']." ". $row['team_name'];
        }
        ?>
        </b>
      </div>
      
        <?php
        if ($row['alternate_layout'] == "0" OR $row['alternate_layout'] == "") {
        ?>
        <div class="totalPoints"><?php echo $row['total'];?></div>
        <?php
        }
        ?>
      <div class="slideshow2" style="text-align:center;">
      <?php
      if (!$row['photo']) {
        echo "<img src=\"/resources/2012/images/tour/bios/_noPhoto.jpg\">";
      } else {
        echo "<img src=\"/resources/2012/images/tour/teams/".$row['photo'].".jpg\" 

class=\"rounded\">";
      }
      if ($row['photo2']) { echo "<img src=\"/resources/2012/images/tour/teams/".$row

['photo2'].".jpg\" class=\"rounded\">"; }
      if ($row['photo3']) { echo "<img src=\"/resources/2012/images/tour/teams/".$row

['photo3'].".jpg\" class=\"rounded\">"; }
      if ($row['photo4']) { echo "<img src=\"/resources/2012/images/tour/teams/".$row

['photo4'].".jpg\" class=\"rounded\">"; }
      ?>
      </div>
      <br clear="both">
      <div class="leftCol">
      <?php
      if ($row['boat_make']) {
        if ($row['boat_make']){
          echo "<b>Boat Brand:</b> " . $row['boat_make']."<br>";
        }
        if ($row['motors']){
          echo "<b>Motors:</b> " . $row['motors']."<br>";
        }
        if ($row['trailer']){
          echo "<b>Trailer:</b> " . $row['trailer']."<br>";
        }
          if ($row['captains_name']) {
            echo "<b>Captain:</b> ".$row['captains_name']."<br>".$row

['captain_location']; 
          } else {
            echo "<b>Captain:</b> ".$row['captain_name']."<br>";
          }
      }
      ?>
      </div>
      <div class="rightCol">
      <?
      if ($row['team_members']){
        echo "<b>Teammates:</b><br> " . $row['team_members']."<br>";
      }
      ?>
      </div>
      <div class="clear"></div>
      <div class="bio">
      <?php
      if (!$row['boat_make']) {
        echo "<h2>Biography Coming Soon</h2>";
      } else {
        if ($row['alternate_layout'] == "0" OR $row['alternate_layout'] == "1"){
          if ($row['sponsors']){
            echo "<b>Sponsors:</b> " . $row['sponsors']."<br><br>";
          }
          if ($row['alternate_layout'] == "0"){
            if ($row['accomplishments']){
              echo "<b>Accomplishments:</b> " . $row['accomplishments']."<br>";
            }
          }
        }
      }
      ?>
      </div>
    </div>
<?php
    
    if ($row['alternate_layout'] == "1" OR $row['alternate_layout'] == "2") {
    ?>
    <div class="grid_8" style="min-height:<?php echo $minHeight; ?>px;">
      <div class="teamName">
        <b> </b>
        <span style="float:right;"><?php echo $row['total'];?></span>
      </div>
      <div class="bio">
       <?php
         if ($row['alternate_layout'] == "2"){
            echo "<b>Sponsors:</b> " . $row['sponsors']."<br><br>";
         }
         echo "<b>Accomplishments:</b> " . $row['accomplishments']."<br>";
       ?>
      </div>
    </div>
    <hr>
    <?php
    }
  }
}
?>
<div class="clear"></div>
<div class="grid_16"><br><br></div>





</body>
</html>
<div class="clear"></div>
    {embed="pro12/.global_footer"}

  The complete code for "Cracka"

Thanks Cracka

 

 

The function of the page is to pull data from a sql DB in which the table has Fishing Team Names with a unique Number associated with the team.

The catch:

Each team has a unique number attached to it.

This team can fish 4 different categories:

LADIES, PRO, SENIOR, and JUNIOR.

We need to show just the PRO on this page.

So lets say Big Joe Fisher is the Team Name and the number is 1234-0, and Big Joe Fisher fishes as a Senior in on event and a Pro in another we seam to get him showing up two times on the page even though the $exclude_list = array is asking to "exclude" Seniors. (and Ladies and Junior types) from the database  "ska_points_tour_2013"

 

Although the "key" is the "team_id" we are looking to just pull all the "PRO" "type" and exclude the other categories.

 

Can you dig it?

 

Thanks for the help.

 

Thanks

Link to comment
Share on other sites

With the exception of "It's not complete code", my original post still stands.  Why not look into that?

 

That being said, as a fix to the existing code, if you move:

  if(!in_array($str, $exclude_list)){
//to below
  $str = $row['type'];

It might work, but I haven't looked through all of the remaining code.

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.