Jump to content

harlequeen

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

harlequeen's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Thanks for that information, I get confused over the punctuation marks. I realise that there could be problems if a user inputs a value that isn't there, but in reality, in this case, its only going to be me and the whole thing is only to make my life easier in the long run. Thanks for all the help. I used it today to do my league darts fixtures and it worked fine!
  2. Hi Darkfreaks Thanks for your help, but I tried the LEFT OUTER JOIN and it doesn't work. Also, the next suggestion doesn't help as I don't have the IFNULL(teams.wk_01,0), in the select as the weekNo is being set by user selection on previous page and could be some other week. When I run the test without the AND '$weekNo' ISNULL I get all the teams in the division as I would expect. When I include that piece of code I don't get any. when I look at the page source view this is what I get. <input type="char" name='team_id[]'size="2" value="9"></td><td> <input type="text" name='teamName[]' size="36" value="Bryn & Trallwm Club A"></td> <input type="hidden" name= 'totalPoints[]' size="3" value="3"></td> <input type="hidden" name= 'gamesWon[]' size="2" value="0"></td> <input type="hidden" name= 'played[]' size="2" value="1"></td> <input type="text" name='weekNo[]' size="2" value=""></td> <td> <SELECT name='Points[]'> <OPTION value=> </OPTION> <OPTION value=1>1</OPTION> <OPTION value=2>2</OPTION> <OPTION value=3>3</OPTION> <OPTION value=4>4</OPTION> <OPTION value=5>5</OPTION> <OPTION value=6>6</OPTION> <OPTION value=7>7</OPTION> <OPTION value=0>0</OPTION>"> </select> </td> I know that some of the teams have a value of 3 in wk_01, but yet the result doesn't show that as you can see above. I also know that some are null. The value of the weekNo in the section above should be 3. I'm really confused now as I don't know why that value is not being brought out from the dbase in the same manner as all the others. Any help anyone?
  3. I'm sorry, I don't know what that means. I didn't get an error like that. What do I need to do to fix this?
  4. Hi I ran it in mysql and from a web page and didn't get an error, just didn't get the result I know I should have had. I should have had a list of teams which had no results in, but got nothing. I tried pre-pending but it still didn't work.
  5. Hi I'm trying to get my select statement to bring back rows which match 2 'where' clause statements but can't get it to work. This is the code I'm using to get it. I am passing the weekNo and the divNo from previous pages. <?php //database connection include'myconnect.php'; $weekNo=$_GET["weekNo"]; $divNo=$_GET["divNo"]; $sql=mysql_query("SELECT teams.teamName, teams.team_id, teams.totalPoints, teams.gamesWon, teams.played, teams.wk_01, contacts.division FROM teams LEFT JOIN contacts ON teams.teamName = contacts.teamName WHERE contacts.division='$divNo' AND '$weekNo' is null "); This doesn't bring me any results back, although I know that some of the rows in the division I'm calling are set to null. If I take out the clause where the '$weekNo' is null I get all the teams in the division I ask for, whether null or not. Any help on this would be appreciated.
  6. Thanks for the replies. I am not using a session variable because I need to set the weekNo from an input form. I changed the code you suggested, as it shouldn't be an array, but I still get the same issue. However, I seem to be a step closer to what I want. I changed my code to: <input type="hidden" size="5" name="weekNo" value=<?php echo $_GET["weekNo"]; ?><td> and that has allowed me to echo out the variable. I put it after the while loop finishes and it is echoing out properly. My update statement is causing me issues now. As the previous pages have created a field called wk_22 in my table, I want to be able to assign that same value to part of the update statement as shown below. $weekNo needs to be a field so that I can post $Points to it. $query="UPDATE teams SET Points = '$Points', $weekNo ='$Points', totalPoints = '$totalPoints', gamesWon = '$gamesWon', played = '$played' WHERE team_id = '$team_id' "; I have no idea how to do this, can someone tell me how please. Hope someone can help. Harlequeen
  7. Hi I have a series of 4 pages which need to have the variable $weekNo (which is set in page 1 by the user - me) passed to them. $weekNo is the name of a field which is being generated in the early pages of this series. I'm doing this through hidden fields in various forms that are required. When I get to the 3rd page I can't seem to pass that value on. I have echoed it out on page 3, then there is the result of a mysql query which is in while loop, bringing me back varying number of rows, but typically 13 or 14. I want to include a hidden field here so that when I submit the values from the form, it will be sent to page 4 where I want the UPDATE statement to include the $weekNo variable so that the statement updates the correct column. I currently have the hidden field within the while loop which I'm sure is incorrect as it's giving me this error. Fatal error: [] operator not supported for strings in /usr/local/psa/home/vhosts/llanelli-ladies-darts.co.uk/httpdocs/checkresults4.php on line 15 Can someone explain to me how I can do this please and if my update statement would be correct. Apologies if my code is long winded and/or strange as I'm learning. Here is my code from page 3 <?php //database connection include'myconnect.php'; $weekNo=$_GET['weekNo']; $divNo=$_GET['divNo']; echo"Hello $weekNo"; $sql=mysql_query("SELECT teams.teamName, teams.team_id, teams.totalPoints, teams.gamesWon, contacts.division FROM teams LEFT JOIN contacts ON teams.teamName = contacts.teamName WHERE contacts.division='$divNo' "); while(@$row=mysql_fetch_array($sql)) { //Form generated from database calling teams identified by Division number in query above. ?> <table width="30%" align="center" border="1"> <form name="inputpoints" method="GET" action="checkresults4.php"> <tr> <td width=40%> <input type="char" name='team_id[]'size="2" value="<? echo $row['team_id'];?>"></td><td> <input type="text" name='teamName[]' size="36" value="<? echo $row['teamName']; ?>"></td> <input type="hidden" name= 'totalPoints[]' size="3" value="<? echo $row['totalPoints'];?>"></td> <input type="hidden" name= 'gamesWon[]' size="2" value="<? echo $row['gamesWon'];?>"></td> <input type="hidden" name= 'gamesWon[]' size="2" value="<? echo $row['weekNo'];?>"></td> <td> <SELECT name='Points[]'> <OPTION value=> </OPTION> <OPTION value=1>1</OPTION> <OPTION value=2>2</OPTION> <OPTION value=3>3</OPTION> <OPTION value=4>4</OPTION> <OPTION value=5>5</OPTION> <OPTION value=6>6</OPTION> <OPTION value=7>7</OPTION> <OPTION value=0>0</OPTION><?php echo $row['Points'];?>"> </select> </td> <?php } ?> </table> <input type="text" size="3" name="weekNo" value="$weekNo"/> <center><input type="submit" value="submit" action="submit"></center> </form> <?php and here is the code for the action page (page 4) //Receiving information from form in teaminputtest.php $team_id[]=$_GET['team_id']; $teamName[]=$_GET['teamName']; $Points[]=$_GET['Points']; $totalPoints[]=$_GET['totalPoints']; $gamesWon[]=$_GET['gamesWon']; $played[]=$_GET['played']; $weekNo[]=$_GET['weekNo']; echo"$weekNo";?><br><? //Looping through each item in the array to get the info foreach ($_GET['team_id'] as $row=>$name) { $team_id = $name; $teamName = $_GET['teamName'][$row]; $Points = $_GET['Points'][$row]; $totalPoints = $_GET['totalPoints'] [$row]; $gamesWon = $_GET['gamesWon'] [$row]; $played = $_GET['played'] [$row]; $weekNo = $_GET['weekNo']; //printing each item to the screen echo "$name "; echo "$teamName "; echo "$Points<br>"; echo "$totalPoints<br>"; }// end for each loop // Count how many teams there are in the division $size=count($_GET['team_id']); echo "$size <br>"; //Set the counter to zero, then loop through while the counter is less than the count figure $i=0; while ($i < $size) { //Call the information from the GET strings passed from previous page. $team_id=$_GET['team_id'] [$i]; $Points=$_GET['Points'] [$i]; $totalPoints=$_GET['totalPoints'] [$i]; $gamesWon=$_GET['gamesWon'] [$i]; $played = $_GET['played'] [$row]; $weekNo = $_GET['weekNo']; //If the team wins add 1 point for winning and count 1 game won. If there are points given, even if its '0' count 1 game played If ($Points >3) { $weekNo=$Points+1; $gamesWon=$gamesWon+1; } else { $Points=$Points; $gamesWon=$gamesWon; } // checking if points are equal to "" if ($Points != NULL) { echo "Points"; $played=$played+1; } else { $played=$played; } //Add up stored total points and this week numbers points $totalPoints=$totalPoints + $Points; echo "Total Points:$totalPoints <br>"; $weekNo = "weekNo"; //Update the database $query="UPDATE teams SET Points = '$Points', $weekNo ='$Points', totalPoints = '$totalPoints', gamesWon = '$gamesWon', played = '$played' WHERE team_id = '$team_id' "; //If there is an erro, let me know mysql_query($query) or die ("Error in query: $query"); //echo to screen the team ID Number //echo "$team_id "; //echo to screen the Points allocated ++$i; }//end while loop print "$Points <br/><br/><em>Updated!</em><br/><br/>"; mysql_close(); ?>
  8. Hi I have a league tables results entry page which is generated by calling the teams in a particular division into a form. In the form I have a checkbox as I want to enter the points scored then check the checkbox so that when I submit the results the checkbox is showing that a result has been posted and adds one to the total of games played. Some of the boxed don't get checked as I don't get the scores all at the same time. However, when I submit the form, the info in the database is adding 1 to the games played total, whether the checkbox is checked or not. <input type="checkbox" name='resultPosted[]' size="1" value="<? echo $row['resultPosted'];?>"></td> and I set the resultPosted variable to 'unchecked' at the beginning of the form and here is my if statement, setting the games played. If ($resultPosted="checked") { $played=$played+1; } else { $played=$played; } Any help would be appreciated.
  9. If I'm understanding you correctly, you want the position of the person in the table? So if they are first, it shoudl say 1. If that is the case I think you can count the rows in the table which is generated by your query and then output the variable($size in the example below) in the cell, as you are doing for the other variables. $size=count($_GET['position']); Hope this is what you mean. Harlequeen
  10. HI Yes, that fixed it. I didn't realise that it was a problem because I was able to echo out the values. Thanks for that, you've been a great help. Cheers Harlequeen
  11. Hi Yes, I see the "$Points <br/><br/><em>Updated!</em><br/><br/>"; line being printed for every iteration. Here is the code for the form, but I don't think it can be that as I'm able to echo the values I want as part of the while loop <?php //database connection include'myconnect.php'; $sql=mysql_query("SELECT teams.teamName, teams.team_id, contacts.division FROM teams LEFT JOIN contacts ON teams.teamName = contacts.teamName WHERE contacts.division=4 "); while(@$row=mysql_fetch_array($sql)) { //Form generated from database calling teams identified by Division number in query above. ?> <table width="30%" align="center" border="1"> <form name="inputpoints" method="GET" action="checkresults3.php"> <tr> <td width=40%> <input type="char" name='team_id[]'size="2" value=" <? echo $row['team_id'];?>"></td><td> <input type="text" name='teamName[]' size="36" value=" <? echo $row['teamName']; ?>"></td> <td> <SELECT name='Points[]'> <OPTION value=1>1</OPTION> <OPTION value=2>2</OPTION> <OPTION value=3>3</OPTION> <OPTION value=4>4</OPTION> <OPTION value=5>5</OPTION> <OPTION value=6>6</OPTION> <OPTION value=7>7</OPTION> <OPTION value=0>0</OPTION><?php echo $row['Points'];?>"> </select> </td> <?php } ?> <input type="submit" value="submit" action="submit"> </table> </form> <?php When I go into phpMyAdmin and put a similar statement in there( to check the syntax) it updates - although it is only 1 entry. Regards H
  12. Hi I have a form which passes 3 values x 14 instances to a processing page. I am getting the arrays of the variables and am able to echo to screen to check that the pairs of values that I want are there. This all works OK. Then I have an update statement which should go to the sprcified table, update the column with the values from the arrays where the condition is met. However, it just isn't updating. I don't get an error message unless there is a problem in the code (I set one to check it, then took it out). My code is below, could someone please look and tell me if they can see the problem. I connect to my database by calling a connect file, which is correct as it is getting the information for the form page correctly. I'm going cross eyed looking at it now. Any help would be appreciated. <?php //database connection include'myconnect.php'; //Receiving information from form in teaminputtest.php $team_id[]=$_GET['team_id']; $teamName[]=$_GET['teamName']; $Points[]=$_GET['Points']; //Looping through each item in the array to get the info foreach ($_GET['team_id'] as $row=>$name) { //Looping through each item in the array to get the info $team_id = $name; $teamName = $_GET['teamName'][$row]; $Points = $_GET['Points'][$row]; //printing each item to the screen echo "$name "; echo"$teamName "; echo "$Points<br>"; }// end for each loop // Count how many teams there are in the division $size=count($_GET['team_id']); echo "$size <br>"; //Set the counter to zero, then loop through while the counter is less than the count figure $i=0; while ($i < $size) { //Call the information from the GET strings passed from previous page. $team_id=$_GET['team_id'] [$i]; $Points=$_GET['Points'] [$i]; //Update the database $query="UPDATE teams SET Points = '$Points' WHERE team_id = '$team_id' "; //If there is an erro, let me know mysql_query($query) or die ("Error in query: $query"); //echo to screen the team ID Number echo "$team_id "; //echo to screen the Points allocated print "$Points <br/><br/><em>Updated!</em><br/><br/>"; ++$i; }//end while loop mysql_close(); ?>
  13. Thanks for all your help everyone. The penny finally dropped when I was telling a colleague that PHP was finicky about cases and I suddenly realised what the problem was. Thanks again. Harlequeen
  14. That doesn't make any difference at all, the same thing is being passed through the url. Cheers Harlequeen
  15. Hi Yes, I did put it in " " but that just didn't echo anything at all. As I said in my post when I tried " " nothing echoed and when I use ' ' just $Points is printed. If I don't put anything but echo $Points in nothing is printed. It should output a number which I've entered using this form. Is there something amiss with the form, perhaps. <table width="30%" align="center" border="1"> <form name="inputpoints" method="GET" action="checkresults3.php"> <tr> <td width=40%> <input type="char" name='team_id[]'size="2" value=" <? echo $row['team_id'];?>"></td><td> <input type="text" name='teamName[]' size="36" value=" <? echo $row['teamName']; ?>"></td> <td> <SELECT name='points[]'> <OPTION value=1>1</OPTION> <OPTION value=2>2</OPTION> <OPTION value=3>3</OPTION> <OPTION value=4>4</OPTION> <OPTION value=0>0</OPTION><?php echo $row['Points'];?>"> </select> </td> As far as I can see from the url the values are being passed as shown. [color=purple]checkresults3.php?team_id[]=+5&teamName[]=+Bristol+Hotel&points[]=4&team_id[]=+22&teamName[]=+Duke+of+Wellington&points[]=3&team_id[]=+40&teamName[]=+Pontyates+RFC&points[]=1[/color] I will want to do further things with the information, but need to know that the values are there. I appreciate your help, but I did try both methods and couldn't get anything out. Harlequeen
×
×
  • 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.