Help in removin gDuplication of headings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Rob (SA)
    Lieutenant Colonel

    • Nov 2006
    • 586

    Help in removin gDuplication of headings

    Hi Folks,

    I have the following script that is causing duplication of headings - which I do not want to see.

    I have been building this page by cut and paste over time due to no experiance in writting script or php.

    Please excuse the mess for those that know - if it needs cleaning your advice is always welcome.

    PHP Code:
    <?php
    $connect 
    mysql_connect("localhost""******_robert""******h") or
    die (
    "Hey loser, check your server connection.");
    mysql_select_db("******_Members");
    $quey1="select * from _Form_Nr_2 ORDER BY `surname` ASC, `name` ASC";
    $result=mysql_query($quey1) or die(mysql_error());
    ?>
    <!------------------------------------------------------------------>
    <!           THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE         >
    <!------------------------------------------------------------------>
    <table border=2 width="85%" bordercolor="#D3E2FE" bordercolorlight="#FFFFFF" bordercolordark="#AFBCDB" style="font-size:11px" cellspacing=0>
    <!------------------------------------------------------------------>
    <!                  THIS SECTION CHANGES THE MAIN HEADING           > 
    <!------------------------------------------------------------------>
    <caption><b><font style="font-size:16px" color="#00008B" face="Arial">
    MEMBERS</font><b><caption>
    <!------------------------------------------------------------------->
    <!    THIS SECTION FETCHES THE INFORMATION FROM THE MYSQL TABLE      >  
    <!------------------------------------------------------------------->
    <?php
    $counter 
    = array();
    $last_surname "";
    $firstNAsAString "";
    while(
    $row=mysql_fetch_array($result))
    {
    //----------------------------------------------------------------------------------------------------
    // THIS SECTION ADDS 3 EMPTY LINES IF THERE IS A SPLIT BUT ONLY AFTER SOME RECORDS HAVE BEEN DISPLAYED
    //----------------------------------------------------------------------------------------------------
    if($i AND $row['surname'] != $last_surname)
    {
    echo 
    '<tr>
    <td colspan="3">&nbsp;</td>
    </tr>'
    ;
    }
    //------------------------------------------------------
    //            THIS SECTION ADDS HEADINGS                
    //------------------------------------------------------
    //if ($row['surname'] != $last_surname)
    {
    echo
    '<tr>
    <td bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>CELL NUMBER</b></font></td>
    <td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>FULL NAME</b></font></td>
    <td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>E-MAIL</b></font></td>
    </tr>'
    ;
    }
    echo 
    '<tr>
    <td align="center" bgcolor="#FFFFFF">
    <font style="font-size:11px" color="#00008B" face="Arial">'
    ;
    echo 
    $row['cell_phone'];
    echo
    '</td>
    <td bgcolor="#FFFFFF">
    <font style="font-size:11px" color="#00008B" face="Arial">'
    ;
    echo 
    '<option value="'.$row['surname'].', '.$row['name'].'">'.$row['surname'].', '.$row['name'].'</option>';
    echo
    '</td>
    <td align="center" bgcolor="#FFFFFF">
    <font style="font-size:11px" color="#FF0000" face="Arial">'
    ;
    echo 
    $row['email'];
    echo
    '</td></tr>';
    //if($row['surname'] != $last_surname)
    //{
    // the first n words to extract $n = 4;
    // extract the words $words = explode(" ", $row['surname']);
    // chop the words array down to the first n elements $firstN = array_slice($words, 1, $n-1);
    // glue the 3 elements back into a spaced sentence $firstNAsAString = implode(" ", $firstN);
    //}
    if(!isset($counter[$firstNAsAString]))
    $counter[$firstNAsAString] = 0;
    else
    $counter[$firstNAsAString]++;
    $last_surname $row['surname'];
    $i++;

    }
    echo 
    '</table>';
    ?>
    Kind Regards
    Rob
    www.gnjgf.co.za
    www.oryan-projects.com
Working...
X