I would modify these lines here, you have a couple of options, set a request param on the anchor of TAB 2, or a hidden input to indicate which tab was clicked, you would need some PHP code to set which tab is active, so you need an "active" style for that as well. I would not recommend this method for long term maintenance but for your code snippet this should be fairly simple. I have not tested the code, but you should get the concept

            <?php
              $tab1Active = "";
              $tab2Active = "";
              if (empty($_REQUEST["whichTab"])) $_REQUEST["whichTab"] = 1;
              if (!empty($_REQUEST["whichTab"]) && $_REQUEST["whichTAB"] == 2) {
                  $tab2Active = 'class="active"';
              }
                else {
                  $tab2Active = 'class="active"';
              }  
            ?>
            <ul>
                <input type="hidden" name="whichTab" id="whichTab" value="{$_REQUEST["whichTab"]}">
                <li><a {$tab1Active} href="#tabs-1" onclick="document.getElementById('whichTab').value = 1;" >Quarter 1</a></li>
                <li><a {$tab2Active} href="#tabs-2" onclick="document.getElementById('whichTab').value = 2;">Quarter 2</a></li>
            </ul>

Just a question, why not filter the results when you do your query with a where statement "select date, ads, visible from table where visible = 1".

Secondly, how are you fetching the data to your PHP ?, most common way to get your results out would be :

$result = $mysqli->query($query)

//start a table here

$icount  = 0;
while ($record = $result->fetch_object()) {
     //make the table row

     if ($record->visible == 1 && $record->ads != 0) {
       echo " $icount {$record->DATE} {$record->ads} {$record->visible} ";   
     }
     //close the table row
     $icount++;

}

//end table here