Results 1 to 7 of 7

Thread: create dynamic columns and populate from MySQl

  1. #1
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default create dynamic columns and populate from MySQl

    Hi Folks,

    I have a page where I require some help - please.

    http://www.gnjgf.co.za/stevie/drawtest.php

    On the left I have a combobox which has three options - 2,3 or 4

    In the center is a page that populates from mySql and arranges itself in order of handicap.

    My request in assitance is this:

    Can I link the 2,3 or 4 selction to create either 4 columns, 6 columns or 8 columns?

    Secondly once this is done the columns as you see them would not appear as two columns but as 4,6 or 8 and populated according to handicap reading from left to right.

    I look forward to your replies.

    Regards
    Rob
    Last edited by Rob (SA); 09-19-2009 at 09:04 PM.

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Do you mean, like, if a person selects the number 4, then it will return 4 columns, and choosing 6 would return 6 columns?

    If so, it's possible to have a request to display a certain amount of columns in ascending order from left to right.

    But I'd need to be sure that's what you're looking to do.
    - Josh

  3. #3
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi Josh,

    thanks for the reply.

    It is nearly as you say it.

    If a person selects 2 it would result in 4 columns, 3 result in 6 and 4 result in 8 columns

    the headings would have recuring fields (i.e Fullname, h/Cap).

    If it displays 2 columns then the frist two names from the list in ascending order will be added to the rows and populate the rows until alll the names are complete.

    If it is 4 columns then it would select the first 4 names and populate their fullnames and H/Caps in ascending order until all th enames from each event are complete.

    And so on, and so on.

    If the script is too complicated for the columns expansion then please let me know how I can populate the columns from left to right using 4 columns, 6 columns or 8 columns.

    I will then have to create 3 extra pages.

    Regards
    Rob

  4. #4
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    I see, so if I select "2" I get 4 columns, etc as you say.

    So, selecting 2 would give me:
    [Full Name, H/CAP] // [Full Name, H/CAP]

    and selecting 3 would give me:
    [Full Name, H/CAP] // [Full Name, H/CAP] // [Full Name, H/CAP]

    and 4 would be:
    [Full Name, H/CAP] // [Full Name, H/CAP] // [Full Name, H/CAP] // [Full Name, H/CAP]

    If so, it's very easy to split a query by using mysql LIMIT syntax, and then separate into the amount that is selected.

    Can you post the code to that page?
    - Josh

  5. #5
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi Josh,

    I have this on my current page

    PHP Code:
    <html>
    <
    head>
    <
    META NAME="keywords" CONTENT="submit custom scorecard golf create golfing scorecards handicap markings betting course courses">
    <
    META NAME="description" CONTENT="Create a Custom Golf Scorecard for your favorite course">
    <
    META NAME="ROBOTS" CONTENT="ALL">
    <
    LINK REL=STYLESHEET TYPE="text/css" HREF="http://www.gnjgf.co.za/stevie/style.css" TITLE="Main css">
    <
    link rel="stylesheet" type="text/css" media="print" href="main-print.css">

    <
    fieldset>
    <
    legendPLAYERS IN GROUP</legend><br>
    Please use the box below to select the amount of players you would like in each group               
    <br>
    <
    tr><center><td colspan="1" align="center" class="heading"><select name="groupnumber" size="1">

    <
    select name="groupnumber" size="1" onChange="javascript:document.group.submit();return
    <option value='2'>2</option>
    <option selected value='3'>3</option>
    <option value='4'>4</option></td>
    </tr></center>
    </select>
    </fieldset>
    </td> 

  6. #6
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I also have this on the same page

    I hope this is what you are requesting.

    This section of script might be a bit jumbled as it has been done with a lot of cut paste

    Thanks again for your help

    PHP Code:
    <?php

    $connect 
    mysql_connect("localhost""e*****_*****""*******") or

    die (
    "Hey loser, check your server connection.");

    mysql_select_db("eghfya_******");

    $quey1="select * from _Form_Nr_3 ORDER BY `i_wish_to_play` ASC, `my_handicap_is` 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">
    </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="6">&nbsp;</td>
    </tr>'
    ;
    }
    //------------------------------------------------------
    //            THIS SECTION ADDS HEADINGS                
    //------------------------------------------------------
    if ($row['i_wish_to_play'] != $last_wish_to_play) {
    echo 
    '<tr>
    <td colspan="6" 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 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>';

    ?>

  7. #7
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi Josh,

    An example of what I amtrying to achieve can be seen at this link

    http://www.gnjgf.co.za/draws.php and by making a selection in the top left hand combobox - a view of what I am trying to do is then visible in the iframe.

    my objective is to get this to be by selction of 2, 3 or 4 and thus generate the page you have just viewed thus saving us adminitrators a huge amount of time.

    I look forward to your replies

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •