LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2002, 06:23 AM   #1
mounters
LQ Newbie
 
Registered: Feb 2002
Location: England
Distribution: SuSE 7.3 prof
Posts: 9

Rep: Reputation: 0
PHP multiple self submissions & database updates


I am attempting to create a web based management system for a hockey club using php and mysql; part of this is enabling people to select a team to play. I want to add the data fixture_id from tables fixtures and player_id from table members into a table matchsquad.

I thought the best idea would be to use multiple self submission forms as the palyers are to be listed in drop down boxes, and to prevent the same person being selected twice after each player is selected this must be submitted to teh match_squad table, the query for getting the available players then checks against the members and matchsquad table so that selected palyers are ommited.

My main problem is when selecting the match to select the squad for, what will be the best way for me to pass the fixture_id to each player submission so the correct fixture_id is associated with the player_id in the matchsquad table? Could I have a seperate self submission form for the match date and then pass the fixture_id as a global variable to all the individual player selections?

Any help gratefully received,
Cheers Mounters
 
Old 03-11-2002, 09:58 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
You lost me at the third paragraph. Take a step back and describe the screens and user interaction a bit better. And what exctly is the fixture table? Teams?
 
Old 03-12-2002, 03:12 AM   #3
Syncrm
Member
 
Registered: Aug 2001
Location: Lansing, Michigan
Distribution: slackware8+
Posts: 472

Rep: Reputation: 30
yeah, i have no bloody idea what he's talking about either.

but these four little (maybe not..?) words always help me when i'm coding PHP: post submission error handling.

:-)
 
Old 03-12-2002, 06:31 AM   #4
mounters
LQ Newbie
 
Registered: Feb 2002
Location: England
Distribution: SuSE 7.3 prof
Posts: 9

Original Poster
Rep: Reputation: 0
The tables are:
fixtures
fixture_id - primary key
home
away
match_date
match_time

members
player_id - primary key
name
email
...other personal info

matchsquad
fixture_id - primary key
player_id - primary key
...other details about result

Screen layout:
Select fixture: <select with all fixtures displayed>

position 1 <select with all players - those already selected to play on that day>
to position 16

When each position is selected the player_id must be added to the matchsquad table with the fixture_id. I think I have just been dim as I can use a hidden input tag to send the fixture_id with each submission of a player.

mounters
 
Old 03-12-2002, 05:18 PM   #5
mounters
LQ Newbie
 
Registered: Feb 2002
Location: England
Distribution: SuSE 7.3 prof
Posts: 9

Original Poster
Rep: Reputation: 0
Ok, worked out the self submission is a very messey way of solving this. So, does anyone know if the creation of dynamic drop down menus to a depth of upto 16 menus is a feasible idea. Or would I be better outputting all the available players in tabular form with check buttons to select them. I like the drop down as it would probably look the tidiest but judging by a quick trawl with google could be very complicated to code.

Any ideas gratefully received.
Mounters
 
Old 03-13-2002, 12:00 AM   #6
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
A drop down for 16 players would be rough to go through. I thought of having two select boxes one for players and one for positions. Select your player then your position and hit a button. Here is a rough sample:

Let me know if this is anything like what you are trying to do.

Code:
<SCRIPT language="JavaScript">

<!-- Begin

function assign(playerBox, positionBox, comboBox )
{
   var arrPlayerBox = new Array();
   var arrPositionBox = new Array();
   var arrAbox = new Array();
   var arrLookup = new Array();

   var i;
   var ts = -1;
   var fs = -1;

   var tLength = 0;
   for (i = 0; i < positionBox.options.length; i++)
   {
      if ( positionBox.options[i].selected )
      {
         ts = i;
      }
      else
      {
         arrLookup[positionBox.options[i].text] = positionBox.options[i].value;
	     arrPositionBox[tLength] = positionBox.options[i].text;
	     tLength++;
      }
   }
   var fLength = 0;
   for(i = 0; i < playerBox.options.length; i++)
   {
      if ( playerBox.options[i].selected )
	  {
	     fs = i;
	  }
	  else
	  {
	     arrLookup[playerBox.options[i].text] = playerBox.options[i].value;
	     arrPlayerBox[fLength] = playerBox.options[i].text;
         fLength++;
	  }
   }
   if ((fs < 0) || (ts < 0) )
   {
      return;
   }
   
   var newOpt = new Option();
   newOpt.value = playerBox.options[fs].value;
   var newtext = playerBox.options[fs].text + ": " + positionBox.options[ts].text;
      newOpt.text = newtext;
//   newOpt.text = positionBox.options[ts].text;

   var alength = comboBox.options.length;
   comboBox[alength] = newOpt;

   playerBox.length = 0;
   positionBox.length = 0;

   var c;
   for(c = 0; c < arrPlayerBox.length; c++)
   {
      var no = new Option();
      no.value = arrLookup[arrPlayerBox[c]];
      no.text = arrPlayerBox[c];
      playerBox[c] = no;
   }
   for(c = 0; c < arrPositionBox.length; c++)
   {
      var no = new Option();
      no.value = arrLookup[arrPositionBox[c]];
      no.text = arrPositionBox[c];
      positionBox[c] = no;
   }
}

//  End -->

</script>

<form name="PlayerPosition" action="/positions.php" METHOD="POST">

<center><table><tr><td>
<select multiple size="16" name="Positions" style="width:100">
<option value="p1">Position1</option>
<option value="p2">Position2</option>
<option value="p3">Position3</option>
<option value="p4">Position4</option>
<option value="p5">Position5</option>
<option value="p6">Position6</option>
<option value="p7">Position7</option>
<option value="p8">Position8</option>
<option value="p9">Position9</option>
<option value="p10">Position10</option>
<option value="p11">Position11</option>
</select>

</td>
<td align="center" valign="middle">
<select multiple size="16" name="Players" style="width:100">
<option value="1">Fred</option>
<option value="2">Barney</option>
<option value="3">Betty</option>
<option value="4">Pebbles</option>
<option value="5">George</option>
<option value="6">Kenny</option>
<option value="7">Kyle</option>
<option value="8">Bob</option>
<option value="9">Judy</option>
<option value="10">Stan</option>
<option value="11">Cartman</option>
</select>

</td>
<td align="center" valign="middle">
<input type="button" onClick="assign(this.form.Positions,this.form.Players,this.form.Combo)" value=">>">
</td>
<td>
<select multiple size="16" name="Combo" style="width:200">
</select>
</td></tr></table></center>
</form>

Last edited by crabboy; 03-13-2002 at 12:01 AM.
 
Old 03-13-2002, 05:24 AM   #7
mounters
LQ Newbie
 
Registered: Feb 2002
Location: England
Distribution: SuSE 7.3 prof
Posts: 9

Original Poster
Rep: Reputation: 0
Hadn't really thought about doing it that way, but I like it.
Thanks for the help.
Mounters
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple installs of same package in RPM database kamdh Fedora 10 10-15-2015 08:18 AM
Deploy updates to multiple servers Risc91 Red Hat 1 03-02-2005 01:23 PM
Unable to Access Database Multiple Times tjherman Linux - Software 0 10-25-2004 11:17 AM
Redhat WS3 updates on multiple machines seeone Red Hat 0 08-22-2004 10:04 PM
Chroot & php cannot connect to tyhe database dominant Linux - Newbie 4 07-03-2004 05:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration