Results 1 to 12 of 12

Thread: link combobox to dynamically create columns
      
   

  1. #1
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    586

    Default link combobox to dynamically create columns

    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 selection to create either 4 columns, 6 columns or eight 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.

  2. #2
    Join Date
    Apr 2006
    Location
    X marks the spot
    Posts
    8,332

    Default Re: link combobox to dynamically create columns

    Rob

    Im not an expert here but i think you are going to have to create the combo box within the script also rather than LINK to the out put as the combo is javascripted itself if you follow what i mean...

    Karen

    VodaHost

    Your Website People!
    1-302-283-3777 North America / International
    02036089024 / United Kingdom
    291916438 / Australia

    ------------------------

    Top 3 Best Sellers

    Web Hosting - Unlimited disk space & bandwidth.

    Reseller Hosting - Start your own web hosting business.

    Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)



  3. #3
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    586

    Default Re: link combobox to dynamically create columns

    Hi Karen,

    Thanks for the reply.

    You are more than likely correct.

    If I could find help on that at first it will be a big step forward for me.

    The other part I think would be a lot more simple for those who know Php and MySQL.

  4. #4
    Join Date
    Jan 2008
    Location
    Colorado
    Posts
    78

    Default Re: link combobox to dynamically create columns

    Rob,

    Use javascript to autosubmit the form that you are using for the combo box. Then you will need to build a check into your PHP code to evaluate the selected value and then regenerate the table.

    Your javascript would look something like this:

    Code:
    <form name="group" action="drawtest.php" method="post">
    
    <select name="groupnumber" size="1" onChange="javascript:document.group.submit();return false;">
    
    <option value='2'>2</option>
    <option value='3'>3</option>
    <option value='4'>4</option>
    </select>
    </form>
    Then in your PHP before you generate the table you would do something like:
    PHP Code:
    if(isset($_POST["groupnumber"])){
      switch(
    $_POST["groupnumber"]){
        case 
    2:
           
    4 Columns, Do some stuff...
        break;

        case 
    3:
           
    6 Columns, Do some stuff...
        break;

        case 
    4:
           
    8 Columns, Do some stuff...
        break;
      }


  5. #5
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    586

    Question Re: link combobox to dynamically create columns

    Hi Mattski,

    Thanks for the prompt response.

    I am not a computer technically minded person - so lot of this goes over my head.

    I have been doing more a cut and paste scenarion and trying to learn in that manner.

    It seems there is a way to get it to work and thats positive - can you perhaps help further?

  6. #6
    Join Date
    Jan 2008
    Location
    Colorado
    Posts
    78

    Default Re: link combobox to dynamically create columns

    Rob,

    If you post your code I can take a look at it.

    I'm assuming you are using a while loop to generate your table. One thing you can do is add a counter in the loop based on the value of "groupnumber". Then in your while loop you don't close out the table row until you get to the specified number of columns. Then close out the row, start a new one and reset your counter.

  7. #7
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    586

    Default Re: link combobox to dynamically create columns

    Hi,

    Thank for the reply.

    Not having great script writing skills and being more of a cut and paste guy this information might be a little jumbled.

    I currently serves its purpose but I am sure could be improved.


    PHP Code:
    <?php
    $connect 
    mysql_connect("localhost""*****_******""******") or
    die (
    "Hey loser, check your server connection.");
    mysql_select_db("e*****_M******");
    $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>';
    ?>

  8. #8
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    586

    Default Re: link combobox to dynamically create columns

    Hi this is the other section of the page that I am trying to link to the previous posting.

    This coud ideally be on another page that would carry authorisation to make this change (i.e password protected for administrator/s)

    Thanks for your help in this matter I appreciate it

    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> 

  9. #9
    Join Date
    Jan 2008
    Location
    Colorado
    Posts
    78

    Default Re: link combobox to dynamically create columns

    Rob,

    If you want this to be set in an admin section I would recommend storing the value in your database in some sort of configuration table and then querying on that value before you generate your table.

    What you are trying to do is absolutely possible but it's a little complicated and it's helpful to know some more advanced programming skills before tackling a project like this. Cutting and pasting is fine for basic applications but for what you are trying to do, you need to learn to understand the code you are writing. For example the <option> tags that you have in your first post are not being used in this design if all you are doing is outputting a table.

    You might want to pick up a book or two on PHP and MySQL programming. The MySQL website and PHP website would also be valuable resources for learning some of this stuff.

    I'd be happy to help you work through some of this if you like.

  10. #10
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    586

    Default Re: link combobox to dynamically create columns

    Hi MAttski,

    I would be please to acept any help

  11. #11
    Join Date
    Jan 2008
    Location
    Colorado
    Posts
    78

    Default Re: link combobox to dynamically create columns

    Rob,

    Sorry, got busy with work/life etc. Didn't mean to leave you hanging here. Feel free to email me and we can discuss this. I can help you get it worked out but it may be easier to do over email.

    Thanks,
    Matt

  12. #12
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    586

    Default Re: link combobox to dynamically create columns

    Hi Matt,

    Thanks I have treied but unfortunatly the submit from the site does not seem to respond favourably,

    Please try my email and I will be sure to contact you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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