Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
Thread Tools
  #1  
Old 09-19-2009, 08:09 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
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.
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 09-19-2009, 08:25 PM
Karen Mac's Avatar
General & Forum Moderator
 
Join Date: Apr 2006
Location: X marks the spot
Posts: 8,474
Send a message via MSN to Karen Mac
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
__________________
KMAC Enterprise
Missouri Free Classified Ads
Charming Noveltees~Sports Logos Charms

I've learned that artificial intelligence is no match for natural stupidity!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 09-19-2009, 08:33 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
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.
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 09-19-2009, 09:27 PM
mattski's Avatar
Master Sergeant
 
Join Date: Jan 2008
Location: Colorado
Posts: 64
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;
  }

__________________
Mattski

http://www.ScorpioFire.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 09-19-2009, 09:33 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
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?
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 09-20-2009, 06:16 PM
mattski's Avatar
Master Sergeant
 
Join Date: Jan 2008
Location: Colorado
Posts: 64
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.
__________________
Mattski

http://www.ScorpioFire.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old 09-20-2009, 10:12 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
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>';
?>
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old 09-20-2009, 10:16 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
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> 
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old 09-21-2009, 05:55 AM
mattski's Avatar
Master Sergeant
 
Join Date: Jan 2008
Location: Colorado
Posts: 64
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.
__________________
Mattski

http://www.ScorpioFire.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old 09-21-2009, 11:41 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Default Re: link combobox to dynamically create columns

Hi MAttski,

I would be please to acept any help
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old 09-30-2009, 11:38 PM
mattski's Avatar
Master Sergeant
 
Join Date: Jan 2008
Location: Colorado
Posts: 64
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
__________________
Mattski

http://www.ScorpioFire.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old 10-01-2009, 06:15 AM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
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
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT +1. The time now is 11:56 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2005-2009 VodaHost Web Hosting Your Perfect Web Host - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203