Jump to content

PHP_Idiot

Members
  • Posts

    131
  • Joined

  • Last visited

Everything posted by PHP_Idiot

  1. I'm not entirely sure what you mean by this or how I would implement it. I don't have time right now but I will play about with it later this afternoon.
  2. I gave this a go but the results are wrong, as you can see from the table section the 'total' total is correct but the 'dates' total is still only adding the Distinct dates together, rather than the subtotal of each row. Is there a way around this? total dates Average 860 32 26.9
  3. Ok so I have this query: SELECT Venue.VenueName, Venue.VenueID, COUNT( Results.MembershipNo ) AS 'total', COUNT( DISTINCT Results.Date ) AS 'dates', CAST( COALESCE( COUNT( Results.MembershipNo ) / COUNT( DISTINCT Results.Date ) ) AS DECIMAL( 10, 1 ) ) AS 'Average' FROM Position, Player, Results, Venue WHERE Player.MembershipNo = Results.MembershipNo AND Venue.active = 'Y' AND Results.Position = Position.Position AND Venue.VenueID = Results.VenueID AND Results.Date BETWEEN '2013-07-01' AND CURDATE( ) GROUP BY Venue.VenueName ORDER BY Average DESC Which gives this result: VenueNameVenueIDtotaldatesAverage The Globe (Weds)22141623.5 The Globe (Weds)22 141 6 23.5 The Tawny Owl 16 118 6 19.7 The Globe (Mon) 30 110 6 18.3 The Duke Of Wellington 28 90 6 15.0 The Mother Redcap 26 57 4 14.3 The Jolly Milliner 23 79 6 13.2 The Old Red Lion 29 545 10.8 The Enigma Tavern 24 65 6 10.8 The Crown 11 62 6 10.3 The Sportsman 31 18 2 9.0 The Heath Inn 33 27 3 9.0 The Nags Head 32 31 4 7.8 What I really need now is the total of the 'total' column and the total of the 'dates' column so I can divide 'total' by 'dates' to get an average. But everything I try fails, I've used the Sum() function but I can't get it to work properly. Any help would be really appreciated. Cheers
  4. Hi Freaks I believe this is caused by changing from 5.3 to 5.3, but what I can't work out is what the problem actually is! This is the code section that is giving the error: specifically lines 106-9 & 113 $bonusGROUPED[$row[1].$row[2].$row[3]] = $bonusGROUPED[$row[1].$row[2].$row[3]] + $row[4] + $row[5]; //grouped data with bonus chips $pointsGROUPED[$row[1].$row[2].$row[3]] = $pointsGROUPED[$row[1].$row[2].$row[3]] + $row[6]; //creates grouped data for each player with points $totalpointsGROUPED[$row[1].$row[2].$row[3]] = $totalpointsGROUPED[$row[1].$row[2].$row[3]] + $row[4] + $row[5] + $row[6];//creates grouped data for each player with points $playedGROUPED[$row[1].$row[2].$row[3]] = $playedGROUPED[$row[1].$row[2].$row[3]] +1; //creates grouped data for number of times played $GBPCPoints = $totalpointsGROUPED[$row[1].$row[2].$row[3]] * $average_by_venue[$row[3]] ; // calculates number of chips $CHIPS = ceil($GBPCPoints / 1) * 1; //rounds up chipstack to nearest 25 $arrGROUPED[$row[1].$row[2].$row[3]] = array(1 => $row[1], 2 => $row[2], 3 => $row[3], 4 => $bonusGROUPED[$row[1].$row[2].$row[3]], 5 =>$pointsGROUPED[$row[1].$row[2].$row[3]], 6 => $totalpointsGROUPED[$row[1].$row[2].$row[3]], 7 => $playedGROUPED[$row[1].$row[2].$row[3]], 8 =>$CHIPS); //creates new array combining all the above data } To be honest I don't fully understand the error, so perhaps an idiots walk through of potential causes could help me rather than examining the code! Either way any help would be much appreciated. Cheers
  5. Hi Freaks this is more an advice query than an outright call for help. I've just migrated my site to new dedicated server space and now have the option of several CMS plugins that I didn't have before. The site has 2 owners and currently 10 admins, but that number will grow. Currently the admins have no access to site content other than logging results in the admin section. However I want them to have access to a snippets page they can add content too, pictures and text, that builds a feed of interesting things they have come across. The question is should I go through the hassle of building my own, or can any of you good folk recommend any of the following: joomla, concrete5, Drupal, typo3, xoops, SilverStripe, phpwebsite, or Mambo!! If anyone used any of these I'd really appreciate some feedback around what you liked/disliked and how you used it. Thanks a lot
  6. Sorry for the blatant bump, but if anyone has any idea's I'd really appreciate the help
  7. $arr[] = $r + array_fill_keys(range(1,,null); // $arr[] = array(1 => $r[1], 2 => $r[2], 3 => $r[3], 4 => $r[4], 5 => $r[5], 6 => $r[6], 7 => $r[7], 8 => $r[8]); // array values are [1]Player.FirstName , [2]Player.LastName, [3]Venue.VenueName as Venue, [4]Results.MemCard, [5]Results.EarlyReg, [6]Position.Points as Venue_Points, [7]Results.Date } As you can see all I've done is blanks out the previous $arr[] and replaced it with kicken's suggestion and this has solves the initial warning. These are the lines the undefined error is showing for: $bonusGROUPED[$row[1].$row[2].$row[3]] = $bonusGROUPED[$row[1].$row[2].$row[3]] + $row[4] + $row[5]; //grouped data with bonus chips $pointsGROUPED[$row[1].$row[2].$row[3]] = $pointsGROUPED[$row[1].$row[2].$row[3]] + $row[6]; //creates grouped data for each player with points $totalpointsGROUPED[$row[1].$row[2].$row[3]] = $totalpointsGROUPED[$row[1].$row[2].$row[3]] + $row[4] + $row[5] + $row[6];//creates grouped data for each player with points $playedGROUPED[$row[1].$row[2].$row[3]] = $playedGROUPED[$row[1].$row[2].$row[3]] +1; //creates grouped data for number of times played Cheers
  8. Hmm I can't resolve this undefine variable! I tried to set the variables to '=0' but that creates this warning instead: and outputs everything as 0. at least with the undefined variable the output is still correct! Anybody got any ideas I could try? Cheers
  9. Thanks for the help kicken, I'm not sure I did it right but I replaced line 98 with your suggestion and its certainly fixed the issue with line 98 but now I'm getting on line 107, 108, 109 & 110 I have to leave for work now, but I'm wondering if a similar approach to those lines would solve those issues as well. Thanks again for the help
  10. Wow you guys are quick off the mark, ok here is the full script (i've excluded the previous bits as they're not important to this bit) This is used to calculate league standings and chips stacks for a poker league. stored in the database are all the results for every player at every venue for each date played, this is extracted from the db using this: Nearly forgot... Results.MemCard, Results.EarlyReg are the two checkboxes, everything else is always filled in but these could be left blank. $top40 = "SELECT Player.MembershipNo , Player.FirstName , Player.LastName, Venue.VenueName as Venue, Results.MemCard, Results.EarlyReg, Position.Points as Venue_Points, Results.Date FROM Position , Player , Results , Venue WHERE Player.MembershipNo =Results.MembershipNo AND Results.Position =Position.Position AND Venue.VenueID =Results.VenueID AND Results.Date BETWEEN '$BeginDate' AND '$EndDate' ORDER BY MembershipNo, Venue"; //query pulls all info required to calculate final chip stack over the current season $result = mysql_query($top40) or die("Couldn't execute query because: ".mysql_error()); //creates variable holding query results $AvePlayers = "SELECT Venue.VenueName, COUNT( Results.MembershipNo ) , COUNT( DISTINCT Results.Date ) , cast( coalesce( COUNT( Results.MembershipNo ) / COUNT( DISTINCT Results.Date ) ) AS decimal( 10, 1 ) ) AS 'Average' FROM Position, Player, Results, Venue WHERE Player.MembershipNo = Results.MembershipNo AND Results.Position = Position.Position AND Venue.VenueID = Results.VenueID AND Results.Date BETWEEN '$BeginDate' AND '$EndDate' GROUP BY Venue.VenueName ORDER BY Average DESC"; //query pulls all data needed to calculate venue average over the duration of the season $result2 = mysql_query($AvePlayers) or die("Couldn't execute query because: ".mysql_error());//creates variable holding query results $pos=1; //creates variable pos with initial value of 1 $average_by_venue = array(); // creates an array while ($r2 = mysql_fetch_array($result2) ) { $average_by_venue[ $r2['VenueName'] ] = $r2['Average']; } //close while Then a table is drawn and this fills the details in: // Above creates table and headers. Now start the loop. $LastSameVenue =0; //create variable and give value 0 while($r = mysql_fetch_array($result)){ // THIS FIRST LOOP CALLCULATES THE CHIP STACK FOR EACH RESULTw //AND BUILDS ARRAY. $arr[] = array(1 => $r[1], 2 => $r[2], 3 => $r[3], 4 => $r[4], 5 => $r[5], 6 => $r[6], 7 => $r[7], 8 => $r[8]); // array values are [1]Player.FirstName , [2]Player.LastName, [3]Venue.VenueName as Venue, [4]Results.MemCard, [5]Results.EarlyReg, [6]Position.Points as Venue_Points, [7]Results.Date } foreach ($arr as $key => $row) { // THIS SECOND LOOP BUILD AN ARRAY FOR EACH PRSON AT EACH VENUE // ADDING THE POINTS FOR EACH VENUE AND ADDING THE NUMBER OF TIMES // PLAYED AT EACH VENUE. BEAUTY $bonusGROUPED[$row[1].$row[2].$row[3]] = $bonusGROUPED[$row[1].$row[2].$row[3]] + $row[4] + $row[5]; //grouped data with bonus chips $pointsGROUPED[$row[1].$row[2].$row[3]] = $pointsGROUPED[$row[1].$row[2].$row[3]] + $row[6]; //creates grouped data for each player with points $totalpointsGROUPED[$row[1].$row[2].$row[3]] = $totalpointsGROUPED[$row[1].$row[2].$row[3]] + $row[4] + $row[5] + $row[6];//creates grouped data for each player with points $playedGROUPED[$row[1].$row[2].$row[3]] = $playedGROUPED[$row[1].$row[2].$row[3]] +1; //creates grouped data for number of times played $GBPCPoints = $totalpointsGROUPED[$row[1].$row[2].$row[3]] * $average_by_venue[$row[3]] ; // calculates number of chips $CHIPS = ceil($GBPCPoints / 1) * 1; //rounds up chipstack to nearest 25 $arrGROUPED[$row[1].$row[2].$row[3]] = array(1 => $row[1], 2 => $row[2], 3 => $row[3], 4 => $bonusGROUPED[$row[1].$row[2].$row[3]], 5 =>$pointsGROUPED[$row[1].$row[2].$row[3]], 6 => $totalpointsGROUPED[$row[1].$row[2].$row[3]], 7 => $playedGROUPED[$row[1].$row[2].$row[3]], 8 =>$CHIPS); //creates new array combining all the above data } foreach ($arrGROUPED as $key => $row2) { // THIS LOOP NOW TAKES THE ARRAY AND SORTS IT IN ORDER OF NAME // AND THEN CHIPS. $FirstName[$key] = $row2['1']; $LastName[$key] = $row2['2']; $Venue[$key] = $row2['3']; $bonus[$key] = $row2['4']; $Venue_Points[$key] = $row2['5']; $Total_Points[$key] = $row2['6']; $Venue_Play_Count[$key] = $row2['7']; $chipstack[$key] = $row2['8']; //print("- $row2[1] $row2[2] $row2[3] $row2[4] <B>$row2[5]</B> $row2[6] - <BR>"); } array_multisort($FirstName, SORT_DESC, $LastName, SORT_DESC, $chipstack, SORT_DESC, $arrGROUPED); $printedFirst = "NULL"; foreach ($arrGROUPED as $key => $row3) { // THIS LOOP MAKES A NEW ARRAY WITH ONLY THE FIRST OF EACH PESONS RESULT // WHICH IS THERE BEST. WOOHOOO if($row3[1].$row3[2] != $printedFirst){ $arrHIGHEST_RESULT[] = array(1 => $row3[1], 2 => $row3[2], 3 => $row3[3], 4 => $row3[4], 5 => $row3[5], 6 => $row3[6], 7 => $row3[7], 8 => $row3[8]); // print("-- $row3[1] $row3[2] $row3[3] $row3[4] <B>$row3[5]</B> $row3[6] -- <BR>"); } $printedFirst = $row3[1].$row3[2]; } foreach ($arrHIGHEST_RESULT as $key => $row4) { // AND THEN THIS LOOP REORDERS THE NEW ARRAY TO PUT IN ORDER // OF CHIPS. FANTASTIC $FirstName4[$key] = $row4['1']; $LastName4[$key] = $row4['2']; $Venue4[$key] = $row4['3']; $bonus4[$key] = $row4['4']; $Venue_Points4[$key] = $row4['5']; $Total_Points4[$key] = $row4['6']; $Venue_Play_Count4[$key] = $row4['7']; $chipstack4[$key] = $row4['8']; //print("# $row4[1] $row4[2] $row4[3] $row4[4] <B>$row4[5]</B> $row4[6] # <BR>"); } array_multisort($chipstack4, SORT_DESC, $arrHIGHEST_RESULT); foreach ($arrHIGHEST_RESULT as $key => $row3) { // THIS LAST LOOP THEN PRINTS THE ARRAY. FIN if($pos < 51){ if($pos == 51){ $style = "style=\"border-top: solid #F00 4px;\""; }else{ $style = ""; } echo" <tr > <td align=\"center\" $style><a href=\"playerDates.php?FName={$row3['1']}& LName={$row3['2']}\">" . $row3[1] .' '. $row3[2] . "</a></td> <td align=\"center\" $style>" . $row3[8] . "</td> </tr>"; $pos++; $printedFirst = $row3[1].$row3[2]; } } //And close the table. The result is then displayed in this table onscreen as can be seen on the right hand side of this page: www.gbpokerclub.co.uk if you look at www.gbpokerclub.co.uk/script_test.php you'll see the same page with error reporting And if you're wondering no I didn't write all this, I had a huge amount of help from several sources and pieced it together over many many weeks!
  11. Hi Freaks I have a large script that pulls data from my db and does some calculations then presents the results, however, I've recently noticed my error log is HUGE! And it's all because of this: This is line 98: $arr[] = array(1 => $r[1], 2 => $r[2], 3 => $r[3], 4 => $r[4], 5 => $r[5], 6 => $r[6], 7 => $r[7], 8 => $r[8]); Now $r[7] & $r[8[ refer to checkboxes that are often left blank, so I figured an isset() here would solve the issue, but I can't for the life of me get it too work. Oh, and the username isn't a lie, I really do suck at this! Thanks for any help
  12. Solved it. I was looking for an incorrect id and not finding one, thats because there was no id in the first place! simply added id=\"FirstName$counter\" id=\"LastName$counter\" to the <td> rows and all my troubles are solved. Thanks for the advice along the way
  13. Hi Adam Sorry I still don't get it! I've tested the code again, same resuils as previously, I've also re-attached the browser source code from FF and IE, and having been through it line byline, I still can't see any differences. If you have spotted something can you let me know please, this is really starting to bug me now! Thanks a lot [attachment deleted by admin]
  14. Does anyone else have any ideas on this? I'm really stumped here! Cheers
  15. In the source the script gets all the membership details <script type="text/javascript"> function showFN(ID, FNnum, LNnum) { if (ID =='0101006') {document.getElementById(FNnum).value='Steve'; document.getElementById(LNnum).value='..'; } else if (ID =='0101007') {document.getElementById(FNnum).value='Damien'; document.getElementById(LNnum).value='..'; } else if (ID =='0101005') {document.getElementById(FNnum).value='Henry'; document.getElementById(LNnum).value='Steele'; } else //etc etc.... And at the bottom of the page it calls it: <td align="center" valign="center"><input name="Position1" value="1" type="hidden"> <input name="MembershipNo1" size="7" maxlength="7" tabindex="1" onchange="showFN(this.value,'FirstName1', 'LastName1');" type="text"></td> <td align="center" valign="center"><input name="FirstName1" size="15" maxlength="7" readonly="READONLY" type="text"></td> <td align="center" valign="center"><input name="LastName1" size="15" maxlength="7" readonly="READONLY" type="text"></td>
  16. In the source the script gets all the membership details <script type="text/javascript"> function showFN(ID, FNnum, LNnum) { if (ID =='0101006') {document.getElementById(FNnum).value='Steve'; document.getElementById(LNnum).value='..'; } else if (ID =='0101007') {document.getElementById(FNnum).value='Damien'; document.getElementById(LNnum).value='..'; } else if (ID =='0101005') {document.getElementById(FNnum).value='Henry'; document.getElementById(LNnum).value='Steele'; } else //etc etc.... And at the bottom of the page it calls it: <td align="center" valign="center"><input name="Position1" value="1" type="hidden"> <input name="MembershipNo1" size="7" maxlength="7" tabindex="1" onchange="showFN(this.value,'FirstName1', 'LastName1');" type="text"></td> <td align="center" valign="center"><input name="FirstName1" size="15" maxlength="7" readonly="READONLY" type="text"></td> <td align="center" valign="center"><input name="LastName1" size="15" maxlength="7" readonly="READONLY" type="text"></td>
  17. I thought this was the call: onChange=\"showFN(this.value,'FirstName$counter', 'LastName$counter');
  18. this might be easier to read,took out the spacing //Javascript stuff print("<SCRIPT type=\"text/javascript\"> function showFN(ID, FNnum, LNnum) { "); while($row = mysql_fetch_row($query)) { $row[1] = addslashes($row[1]); //adds slashes for jave code $row[2] = addslashes($row[2]); print(" if (ID =='$row[0]') {document.getElementById(FNnum).value='$row[1]'; document.getElementById(LNnum).value='$row[2]'; } else "); //php end print } //php end while print("{document.getElementById(FNnum).value='ID Not In Database';} "); $row[1] = stripslashes($row[1]); //removes slashes so if used later in page $row[2] = stripslashes($row[2]); //it print out name with a slash in it (you may not need this bit) print("}</SCRIPT>");
  19. No I dont think so! the initial page is addvenueresults.php this is the small form that lets the user select the venue and date and number of players. on submitting that you get taken to createform.php which has the include createform4.php pulled into it, it is createform4.php that has the script thats meant to make it all work. The source i included was from createform.php page. in the createform4.php page script is the following piece of js (at least i think thats what it is :-\ //Javascript stuff print("<SCRIPT type=\"text/javascript\"> function showFN(ID, FNnum, LNnum) { "); while($row = mysql_fetch_row($query)) { $row[1] = addslashes($row[1]); //adds slashes for jave code $row[2] = addslashes($row[2]); print(" if (ID =='$row[0]') {document.getElementById(FNnum).value='$row[1]'; document.getElementById(LNnum).value='$row[2]'; } else "); //php end print } //php end while print("{document.getElementById(FNnum).value='ID Not In Database';} "); $row[1] = stripslashes($row[1]); //removes slashes so if used later in page $row[2] = stripslashes($row[2]); //it print out name with a slash in it (you may not need this bit) print("}</SCRIPT>");
  20. Actually in the script below there is ShowFN: print("<tr><td align=\"center\" valign=\"center\"> $counter</td> <td align=\"center\" valign=\"center\">$points</td> <td align=\"center\" valign=\"center\"><input name=\"MemCard$counter\" value=\"25\" type=\"checkbox\" tabindex=\"$counter\"></td> <td align=\"center\" valign=\"center\"><input name=\"EarlyReg$counter\" value=\"25\" type=\"checkbox\" tabindex=\"$counter\"></td> <td align=\"center\" valign=\"center\"><input name=\"Position$counter\" value=\"$counter\" type=\"hidden\"> <input name=\"MembershipNo$counter\" type=\"text\" size=\"7\" maxlength=\"7\" tabindex=\"$counter\"onChange=\"showFN(this.value,'FirstName$counter', 'LastName$counter');\"></td> <td align=\"center\" valign=\"center\"><input name=\"FirstName$counter\" type=\"text\" size=\"15\" maxlength=\"7\" READONLY=\"READONLY\"></td> <td align=\"center\" valign=\"center\"><input name=\"LastName$counter\" type=\"text\" size=\"15\" maxlength=\"7\" READONLY=\"READONLY\"></td> </tr>"); Is this in some way incorrect?
  21. Umm ok. So presumably that is required for it to work in all browsers except ie7 (ie8 compat). How and where should I call that then?
  22. Hi Adam I cant paste the code here because it's over the char limit, but I've attached both FF7 and IE8 (compatibility mode) source codes for you. I hope this is what your meant, thanks for all the help by the way, it's really appreciated Cheers [attachment deleted by admin]
  23. Hi Adam Sorry not entirely sure what you mean but outputted markup! This code is the first part of the process, this allows the user to choose the venue, date and number of players: <form name="form1" method="POST" action="createform.php"> <p>Venue Name <? $query="SELECT VenueName, VenueID FROM Venue ORDER BY VenueName"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query); echo "<select name='Venue' id='Venue' value=''>Venue Name</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)) {//Array or records stored in $nt echo "<option value=\"$nt[VenueID]\">$nt[VenueName] ($nt[VenueID])</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> </p> <?php $monthName = array(1=> "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $today = time(); //stores today's date $f_today = date("Y-M-d",$today); //formats today's date /* build selection list for the year */ $startYr = date("Y", $today); //get the year from $today echo "<select name='Year'>\n"; for ($n=$startYr;$n<=$startYr+3;$n++) { echo " <option value=$n"; if ($startYr == $n ) { echo " selected"; } echo "> $n\n"; } echo "</select>\n"; /* build selection list for the month */ $todayMO = date("n",$today); //get the month from $today echo "<select name='Month'>\n"; for ($n=1;$n<=12;$n++) { echo "<option value=$n\n"; if ($todayMO == $n) { echo " selected"; } echo "> $monthName[$n]\n"; } echo "</select>"; /* build selection list for the day */ $todayDay= date("d",$today); //get the day from $today echo "<select name='Day'>\n"; for ($n=1;$n<=31;$n++) { echo " <option value=$n"; if ($todayDay == $n ) { echo " selected"; } echo "> $n\n"; } echo "</select>\n"; ?> <label> Date Played:<br> </label> <br><br> <label>How Many Players <input name="PlayerNo" type="text" id="PlayerNo" size="2" maxlength="2"><br><br> <input name="Create Form" type="submit" value="Create Results Form"> </label> <P> </form> Once that small form has been submitted you are take to creatform.php, within which is <?php include 'admin/createform4.php'; ?> which holds the code initially posted. This should check to see if the form has been submitted, if not it displays the form if it has it connects to the db to insert the results in the relevant tables. From what I've managed to find so far it seem the culprit is the javascript document.getElementById but I still don't understand whats acctually going wrong with it. So far as I understand IE interprets it incorrectly which (bizarrely) makes it work, whereas other browsers interpret it correctly and it doesn't work! Hope that makes some sense!
  24. Hi freaks Bit of background... I've had the following script in place for sometime, and historically only really used ie7 (I know, I deserve stoning!). Anyway I'm rebuilding the entire site, new template, cross browser compatibile, switched to FF and all its great dev tools. and all is going well. Except this script doesnt function in anything other than IE! Basically a results form is generated from the previous page, once the form is displayed the user enters a bunch of membership numbers in their finishing positions, what is supposed to happen is that after a mambership number is added the following two columns should populate with the coresponding first and last name of that membership nmber. This is important as a sanity/visual check for the user inputting the results. But all I get is grey boxes and not the names (except in IE which works fine!). Now I didn't write this code ( i don't know the first thing about javascript (yet)) but I would appreciate any advice that could help me fix this. Here is all the code used in the include (both the php and script): PS I really appreciate the help <?php //set variables from form fields $Day = $_POST['Day']; $Month = $_POST['Month']; $Year = $_POST['Year']; $Venue = $_POST['Venue']; $PlayerNo = $_POST['PlayerNo']; $beensubmited = $_POST['beensubmited']; $table = "Player"; $table2 = "Results"; for ($PN = 1; $PN <= $_POST['PlayerNo']; $PN++) { ${"MembershipNo$PN"} = $_POST["MembershipNo$PN"]; } /* Data for SQL-server */ $host= "localhost"; /* Address of database server */ $user= "XXXXX"; /* FTP-username */ $password= "XXXXX"; /* FTP-Password */ $database= "XXXXX"; /* name of database */ /* Accessing SQL-Server and querying table */ $con = MYSQL_CONNECT($host, $user, $password) or die ( "<H3>Server unreachable</H3>"); $db = MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>"); //mySQL queries $query = MYSQL_QUERY("SELECT * FROM $table"); //Javascript stuff print("<SCRIPT type=\"text/javascript\"> function showFN(ID, FNnum, LNnum) { "); while($row = mysql_fetch_row($query)) { $row[1] = addslashes($row[1]); //adds slashes for jave code $row[2] = addslashes($row[2]); print(" if (ID =='$row[0]') {document.getElementById(FNnum).value='$row[1]'; document.getElementById(LNnum).value='$row[2]'; } else "); //php end print } //php end while print("{document.getElementById(FNnum).value='ID Not In Database';} "); $row[1] = stripslashes($row[1]); //removes slashes so if used later in page $row[2] = stripslashes($row[2]); //it print out name with a slash in it (you may not need this bit) print("}</SCRIPT>"); ?> <?php //top form copies over venue details BEFORE SUBMITTING if($beensubmited ==""){ echo '<table border="1" width="100%" cellspacing="0" bgcolor="lightgrey" bordercolor="darkgrey">'; echo '<caption align="top"><h3>Venue Details</h3></caption>'; echo "<tr><th>Venue</th><th>Date</th><th>Number of Players</th></tr>"; echo "<tr><td align='center' valign='center'>"; echo "$Venue"; echo "</td><td align='center' valign='center'>"; echo "$Day / $Month / $Year"; echo "</td><td align='center' valign='center'>"; echo "$PlayerNo"; echo "</td></tr></table>"; echo '<br>'; //create Points array per player $pointsArray = array( 1 => 1000, 2 => 800, 3 => 600, 4 => 500, 5 => 400, 6 => 300, 7 => 200, 8 => 100, ); //creates hidden form! print("<form name=\"userform\" method=\"POST\" action=\"createform.php\"> <table border=\"1\" width=\"100%\" cellspacing=\"0\" bgcolor=\"lightgrey\" bordercolor=\"darkgrey\" align=\"left\"> <caption align=\"top\"><h3>Venue Results</h3></caption> <tr><th>Position</th> <th>Points</th><th>Mem. Card</th><th>Early Reg</th><th>Membership Number</th><th>First Name</th><th>Last Name</th></tr> <input name=\"Venue\" type=\"hidden\" value=\"$Venue\"> <input name=\"Date\" type=\"hidden\" value=\"$Year-$Month-$Day\"> <input name=\"PlayerNo\" type=\"hidden\" value=\"$PlayerNo\"> <input name=\"beensubmited\" type=\"hidden\" value=\"Y\">"); //Creates counter to name individual cells for ( $counter = 1; $counter <= $PlayerNo; $counter += 1) { $points = isset($pointsArray[$counter]) ? $pointsArray[$counter] : 50; ; //produces querys form print("<tr><td align=\"center\" valign=\"center\"> $counter</td> <td align=\"center\" valign=\"center\">$points</td> <td align=\"center\" valign=\"center\"><input name=\"MemCard$counter\" value=\"25\" type=\"checkbox\" tabindex=\"$counter\"></td> <td align=\"center\" valign=\"center\"><input name=\"EarlyReg$counter\" value=\"25\" type=\"checkbox\" tabindex=\"$counter\"></td> <td align=\"center\" valign=\"center\"><input name=\"Position$counter\" value=\"$counter\" type=\"hidden\"> <input name=\"MembershipNo$counter\" type=\"text\" size=\"7\" maxlength=\"7\" tabindex=\"$counter\"onChange=\"showFN(this.value,'FirstName$counter', 'LastName$counter');\"></td> <td align=\"center\" valign=\"center\"><input name=\"FirstName$counter\" type=\"text\" size=\"15\" maxlength=\"7\" READONLY=\"READONLY\"></td> <td align=\"center\" valign=\"center\"><input name=\"LastName$counter\" type=\"text\" size=\"15\" maxlength=\"7\" READONLY=\"READONLY\"></td> </tr>"); } //submit Button print("</table><br> <input type=SUBMIT name=action value=\"Done!\"> </form>"); } // end beensubmited blank // Adds form data to DB AFTER SUBMITTING if($beensubmited =="Y"){ $Venue = $_POST['Venue']; $Date = $_POST['Date']; $PlayerNo = $_POST['PlayerNo']; $PlayerNo = $_POST['PlayerNo']; //MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>"); //MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>"); //MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>"); //MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>"); // Make a MySQL Connection $link = mysql_connect("XXXXX", "XXXXX", "XXXXX") or die(mysql_error()); mysql_select_db("XXXXX") or die(mysql_error()); // Insert a row of information into the table "example" echo "Data Inserted!<br />"; mysql_close($link); foreach($_POST as $k=>$v) $$k=$v; for ($PN = 1; $PN <= $_POST['PlayerNo']; $PN++) { ${"MembershipNo$PN"} = $_POST["MembershipNo$PN"]; ${"Position$PN"} = $_POST["Position$PN"]; ${"MemCard$PN"} = $_POST["MemCard$PN"]; ${"EarlyReg$PN"} = $_POST["EarlyReg$PN"]; // Make a MySQL Connection mysql_connect("XXXXX", "XXXXX", "XXXXX") or die(mysql_error()); mysql_select_db("XXXXX") or die(mysql_error()); // Insert a row of information into the table "example" mysql_query("INSERT INTO Results (Date, ResultID, VenueID, MembershipNo, Position, MemCard, EarlyReg) VALUES('$Date', NULL, '$Venue', '${"MembershipNo$PN"}', '${"Position$PN"}', '${"MemCard$PN"}', '${"EarlyReg$PN"}') ") or die(mysql_error()); echo "Data Inserted!<br />"; } } ?>
  25. Your a hero Although your answer didn't work it did make me think about things slightly differently as I didn't understand the syntax you used. So I googled .htaccess syntax and stumbled across the answer: DirectoryIndex /beta2/index.php Woo hoo, thanks for trying to help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.