Change Field Columns to appear as Rows in table

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

    • Nov 2006
    • 586

    Change Field Columns to appear as Rows in table

    Hi Folks,

    I have managed to create a table and also retrieve data from my database.

    However the script needs just a small change I am sure to fix my requirement and that fix is to get the data to fill the row from left to right using the number under the H/C column seen in the table at http://www.gnjgf.co.za/stevie/drawtest_4.php

    Once that is done it can move to the next table - A script to seprate the table to the same page would alsoo be most helpful.

    I look forward to any reply
    Kind Regards
    Rob
    www.gnjgf.co.za
    www.oryan-projects.com
  • Rob (SA)
    Lieutenant Colonel

    • Nov 2006
    • 586

    #2
    Re: Change Field Columns to appear as Rows in table

    Hi Folks,

    It is also probably prudent to post the code to be veiwed if I am looking for help

    PHP Code:
    [$quey1="select * from _Form_Nr_3 ORDER BY `i_wish_to_play` ASC, `my_handicap_is` DESC ";
    $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">
    </font><b><caption>
    <!------------------------------------------------------------------->
    <! THIS SECTION FETCHES THE INFORMATION FROM THE MYSQL TABLE > 
    <!------------------------------------------------------------------->
    <?php
    $counter 
    = array();
    $last_i_wish_to_play "";
    $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['i_wish_to_play'] != $last_wish_to_play){
    echo 
    '<tr>
    <td colspan="8">&nbsp;</td>
    </tr>'
    ;
    }
    //------------------------------------------------------
    // THIS SECTION ADDS HEADINGS 
    //------------------------------------------------------
    if ($row['i_wish_to_play'] != $last_wish_to_play) {
    echo 
    '<tr>
    <td colspan="8" align="center" bgcolor="#FFFFFF"><font style="font-size:11px" color="#00008B" face="Arial"><b>'
    .$row['i_wish_to_play'].'</b></font></td>
    </tr>'
    ;
    echo 
    '<tr>
    <td width=100 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>H/CAP</b></font></td>
    <td width=100 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>H/CAP</b></font></td>
    <td width=100 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>H/CAP</b></font></td>
    <td width=100 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>H/CAP</b></font></td>
    </tr>'
    ;
    }
    echo 
    '<tr><td bgcolor="#FFFFFF"><font style="font-size:10px" 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:10px" color="#00008B" face="Arial">';
    echo 
    $row['my_handicap_is'];
     
    if(
    $row['i_wish_to_play'] != $last_wish_to_play)
    {
    // the first n words to extract
    $n 4;
    // extract the words
    $words explode(" "$row['i_wish_to_play']);
    // chop the words array down to the first n elements
    $firstN array_slice($words1$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_wish_to_play $row['i_wish_to_play'];
    $i++;
    echo 
    '</td></tr>';
     
    }
    echo 
    '</table>';
    ?>
    Kind Regards
    Rob
    www.gnjgf.co.za
    www.oryan-projects.com

    Comment

    • Rob (SA)
      Lieutenant Colonel

      • Nov 2006
      • 586

      #3
      Re: Change Field Columns to appear as Rows in table

      Hi Folks,

      The example prepared using excel might be of help in your deliberation

      Here is the example of what I am looking to achieve
      Kind Regards
      Rob
      www.gnjgf.co.za
      www.oryan-projects.com

      Comment

      Working...
      X