Jay2391 Posted January 30, 2007 Share Posted January 30, 2007 I am looking for a better way to do this ... $games_to_be_played is the amount of maximun games a player will play in a tournament so if the maximun games to be played is "x" number then I should get the same number of "x" $scorX variable to imput scores...or is this even correct....$games_to_be_played = 3;$query = "SELECT * FROM $table "; $result = mysql_query($query2, $tc); while($row = mysql_fetch_array($result)){ if($t_name == $row['t_name'] and $game == $row['game']){ $result_id = $row['result_id']; $player = $row['user_name']; $win = $row['win']; $loss = $row['loss'];; $tie = $row['tie'];; $rank = $row['rank'];; $scor1 = $row['scor1']; $scor2 = $row['scor2']; $scor3 = $row['scor3']; $scor4 = $row['scor4']; $scor5 = $row['scor5']; print "<p><h4$playerbr></h4></p>"; if ($games_to_be_played == 3){ print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 1: <input type="text" name="scor1" size"50" value="' . $_POST['scor1'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 2: <input type="text" name="scor2" size"50" value="' . $_POST['scor2'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 3: <input type="text" name="scor3" size"50" value="' . $_POST['scor3'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; } if ($games_to_be_played == 4){ print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 1: <input type="text" name="scor1" size"50" value="' . $_POST['scor1'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 2: <input type="text" name="scor2" size"50" value="' . $_POST['scor2'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 3: <input type="text" name="scor3" size"50" value="' . $_POST['scor3'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 4: <input type="text" name="scor4" size"50" value="' . $_POST['scor4'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; print '<h4><form action = "samepage.php" method="post"><p>'; print Score Round 5: <input type="text" name="scor5" size"50" value="' . $_POST['scor5'] . '"/><br />' print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; } print '<br><input type="submit" name="submit" size"20" value="Enter Score"/><br /></h4>'; Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 30, 2007 Author Share Posted January 30, 2007 By the way this is the way the lines should look like I was type it in before so I am missing some '' marks and stuffif ($games_to_be_played == 2){ print '<p><h4><form action = "tourney_admin.php" method="post"></p>'; print '<p>Score Round 1: <input type="text" name="scor1" size"10" value="' . $_POST['scor1'] . '"/>'; print '<input type="submit" name="submit" size"20" value="Enter Score"/></h4></p>'; print '<p><h4><form action = "tourney_admin.php" method="post"></p>'; print '<p>Score Round 2: <input type="text" name="scor2" size"10" value="' . $_POST['scor2'] . '"/>'; print '<input type="submit" name="submit" size"20" value="Enter Score"/></h4></p>';} Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 30, 2007 Share Posted January 30, 2007 Next time in the posting form, highlight your code and press the # button.I don't see what your question/problem is either. Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 30, 2007 Author Share Posted January 30, 2007 My question is if there is a better WAY!!!! to create that code I did above....mybe things that will help are ....can I insert a variable in here ...red areaprint '<p>Score Round 1: <input type="text" name="scor1" size"5" value="' . $_POST[[color=red]'scor1'[/color]] . '"/>';the issue is that i can print the boxes but they are all id the same way so I need the input boxes to be unique assing to that playerplayer 1 has 2 input boxesplayer 2 has 2 input boxesplayer 3 has 2 input boxesplayer 4 has 2 input boxes[color=red][font=Verdana]but the boxes are name "scor1 and scor2" in all the lines so when you update scor1 it will update "scor1" in the database for all of the one call "scor1"[/font][/color]so I am trying to figure out a better WAY ....Sorry about the CODE # THING Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 30, 2007 Share Posted January 30, 2007 i think this is what you want to do:[code]<?php $games_to_be_played = 3; $query = "SELECT * FROM your_table"; $result = mysql_query($query, $tc); $i = 1; while($row = mysql_fetch_array($result)){ if($t_name == $row['t_name'] && $game == $row['game']){ echo "<p><h4>". $row['user_name'] ."<br></h4></p>\n"; if($games_to_be_played == 3){ print "<h4><form action=\"". $_SERVER['php_self'] ."\" method=\"post\"><p>\n"; print "Score Round ". $i .": <input type=\"text\" name=\"scor". $i ."\" size\"50\" value=\"". $_POST[scor$i] ."">\n"; print "<input type="submit" name="submit" size"20" value="Enter Score">\n"; print "</form></h4>\n"; } }?>[/code] Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 30, 2007 Author Share Posted January 30, 2007 the code is missing something I tough it was a ' \ ' in this area...value=\"". $_POST[scor$i] ."\">\n";but i get a Parse error: parse error, unexpected T_VARIABLE, expecting ']' in C:\XAMPP\xampp\htdocs\MDO\tourney_admin.php on line 235[code] if($games_to_be_played == 3){ print "<h4><form action=\"". $_SERVER['php_self'] ."\" method=\"post\"><p>\n"; print "Score Round ". $i .": <input type=\"text\" name=\"scor". $i ."\" size\"50\" value=\"". $_POST[scor$i] ."\">\n"; print "<input type="submit" name="submit" size"20" value="Enter Score">n"; print "</form></h4>n";}[/code] Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 30, 2007 Share Posted January 30, 2007 sorry, try this instead:[code]<?php $games_to_be_played = 3; $query = "SELECT * FROM your_table"; $result = mysql_query($query, $tc); $i = 1; while($row = mysql_fetch_array($result)){ if($t_name == $row['t_name'] && $game == $row['game']){ echo "<p><h4>". $row['user_name'] ."<br></h4></p>\n"; if($games_to_be_played == 3){ print "<h4><form action=\"". $_SERVER['php_self'] ."\" method=\"post\"><p>\n"; print "Score Round ". $i .": <input type=\"text\" name=\"scor". $i ."\" size=\"50\" value=\"". $_POST[scor$i] ."\">\n"; print "<input type=\"submit\" name=\"submit\" size=\"20\" value=\"Enter Score\">\n"; print "</form></h4>\n"; } } $i++; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 30, 2007 Author Share Posted January 30, 2007 Parse error: parse error, unexpected T_VARIABLE, expecting ']' in C:\XAMPP\xampp\htdocs\MDO\test.php on line 235[code]<?php $games_to_be_played = 3; $query = "SELECT * FROM your_table"; $result = mysql_query($query, $tc); $i = 1; while($row = mysql_fetch_array($result)){ if($t_name == $row['t_name'] && $game == $row['game']){ echo "<p><h4>". $row['user_name'] ."<br></h4></p>\n"; if($games_to_be_played == 3){ print "<h4><form action=\"". $_SERVER['php_self'] ."\" method=\"post\"><p>\n";[color=red]for me is this line----->[/color] print "Score Round ". $i .": <input type=\"text\" name=\"scor". $i ."\" size=\"50\" value=\"". $_POST[scor$i] ."\">\n"; print "<input type=\"submit\" name=\"submit\" size=\"20\" value=\"Enter Score\">\n"; print "</form></h4>\n"; } } $i++; }?>[/code] Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 30, 2007 Share Posted January 30, 2007 i was afraid of that. try changing this:[code]$_POST[scor$i][/code]to this:[code]$_POST['scor$i'][/code] Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 30, 2007 Author Share Posted January 30, 2007 Well that didn't work so i decided to change I am trying to get drop down menus....but I am having similar issues here is my drop down menu code but it dosen't select the item...the munu box shows up and i can select and click but it dosen't store the values... ??? ??? ???[code] $query_list = "SELECT * FROM $tabler WHERE (tourney_name=\"$tourney_name\")";$result_list = mysql_query($query_list, $tc); print '<h4><form action = "tourney_admin.php" method="post"><p>':print '<p><label>Player: <select name="player_list"> <option value="">- - -Chose an player - -</option>'; while($row_list = mysql_fetch_array($result_list)){ $player_list = $row_list['user_name']; print "<option value=\"$player_list\">$player_list<br></option>"; } print "</select></p>\n"; print '<p><input type="submit" name="change" value="Submit Change" /></label></p> </form>'; [/code] Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 30, 2007 Share Posted January 30, 2007 the selected value will be stored in a variable called[code]$_POST['player_list'][/code]so, somewhere at the top of tourney_admin.php, write[code]echo $_POST['player_list'] ."<br />\n";[/code]and it will print the value of the selected option in the dropdown menu. Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 30, 2007 Author Share Posted January 30, 2007 it was below but it work thanks... Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted January 30, 2007 Share Posted January 30, 2007 [quote author=Jay2391 link=topic=124708.msg517470#msg517470 date=1170194991]it was below but it work thanks...[/quote]fo shizzle Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.