hola hola Posted September 18, 2009 Share Posted September 18, 2009 I feel stupid here... I am updating my sports game report form and now do not want my drop down menu on the form. I only want it to print "<?print $teamname;?>\n"; I and getting a horizontal list of the $teamname (s) associated with the respective $divname. <b>Home Team</b>: <select name="winner"> <?php $query2="SELECT s2010_teams.teamid, s2010_teams.teamname, s2010_divs.divname FROM s2010_teams, s2010_divs WHERE s2010_teams.active = 1 AND s2010_teams.teamdiv = s2010_divs.divid AND s2010_divs.conference = $confid ORDER BY divorder ASC, teamname ASC"; $result2=mysql_query($query2); while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { print "<option value=\"{$teams['teamid']}\""; if ($teams['teamid'] == $score['winner']) { print " selected=\"selected\""; } print ">{$teams['teamname']}</option>\n"; } print "</select>\n"; ?> Please help! My head hurts! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/ Share on other sites More sharing options...
mikesta707 Posted September 18, 2009 Share Posted September 18, 2009 I'm confused, do you just want to print the variable teamname? why dont you just print it? I really dont understand your question, could you possibly clarify? Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920773 Share on other sites More sharing options...
hola hola Posted September 18, 2009 Author Share Posted September 18, 2009 That is exactly what I am looking for... Home Team: (The Respective Team) instead of the <Option> drop down menu with selected $teamname plus all teamnames of that division. I thought I had it right and al getting: Home Team: Team1 Team2 Team3 Team4 Team5 Team6 Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920778 Share on other sites More sharing options...
mikesta707 Posted September 18, 2009 Share Posted September 18, 2009 well the code you posted doesn't do that at all. post the code that creates the output Home Team: Team1 Team2 Team3 Team4 Team5 Team6 but it should look something like while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "Hometeam: ".$teams['teamname']."<br />"; } assuming you wanted to precede each team name with the word Home Team Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920779 Share on other sites More sharing options...
hola hola Posted September 18, 2009 Author Share Posted September 18, 2009 This gets me the previously stated result. <tr><td bgcolor='#FFFF00'><b>Home Team</b>: <?php $query2="SELECT s2010_teams.teamid, s2010_teams.teamname, s2010_divs.divname FROM s2010_teams, s2010_divs WHERE s2010_teams.active = 1 AND s2010_teams.teamdiv = s2010_divs.divid AND s2010_divs.conference = $confid ORDER BY divorder ASC, teamname ASC"; $result2=mysql_query($query2); while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { print "<option value=\"{$teams['teamid']}\""; if ($teams['teamid'] == $score['winner']) { print " selected=\"selected\""; } print ">{$teams['teamname']}</option>\n"; } print "</td><td bgcolor='#FFFF00'><b>Score:</b> <input type=\"text\" name=\"rf\" size=\"2\" maxlength=\"2\" value=\"{$score['rf']}\" /></td></tr>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920785 Share on other sites More sharing options...
mikesta707 Posted September 18, 2009 Share Posted September 18, 2009 that will print out a drop down menu... not the string Home Team: Team1 Team2 Team3 Team4 Team5 Team6 I'm more confused now... do you want or not want a drop down box Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920798 Share on other sites More sharing options...
hola hola Posted September 18, 2009 Author Share Posted September 18, 2009 I do not want the Drop Down. I am looking for the Team to be presented like: <b>Status:</b> <?print $status;?> Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920806 Share on other sites More sharing options...
mikesta707 Posted September 18, 2009 Share Posted September 18, 2009 then do exactly that.. while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "<b>Status: </b> " . $teams['status']."<br />"; } assuming that the value for status was under the column status from your query Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920808 Share on other sites More sharing options...
hola hola Posted September 18, 2009 Author Share Posted September 18, 2009 The Status was an example of another field that exists on the form. Here is my full code: case 'editscore': $confid = intval($_GET['conf']); $winid=$_POST['winid']; $query="SELECT s2010_wins.status, s2010_wins.windate, s2010_wins.wintime, s2010_wins.wincomments, s2010_wins.teamcomments, s2010_wins.field, s2010_wins.field_no, s2010_wins.winner, s2010_wins.loser, s2010_wins.winortie, s2010_wins.rf, s2010_wins.ra, s2010_teams.teamname AS winningteam, s2010_teams2.teamname AS losingteam FROM s2010_wins, s2010_teams, s2010_teams AS s2010_teams2 WHERE s2010_wins.winid=$winid AND s2010_teams.teamid = s2010_wins.winner AND s2010_teams2.teamid = s2010_wins.loser"; $result=mysql_query($query); $score = mysql_fetch_array($result, MYSQL_ASSOC); $wincomments = str_replace('"','"',$score['wincomments']); $wincomments = str_replace("'",''',$wincomments); $teamcomments = str_replace('"','"',$score['teamcomments']); $teamcomments = str_replace("'",''',$teamcomments); $field = str_replace('"','"',$score['field']); $field = str_replace("'",''',$field); $status = str_replace('"','"',$score['status']); $status = str_replace("'",''',$status); $field_no = str_replace('"','"',$score['field_no']); $field_no = str_replace("'",''',$field_no); $month=date('m',$score['windate']); $day=date('d',$score['windate']); $year=date('Y',$score['windate']); $hour=date('g',$score['wintime']); $minute=date('i',$score['wintime']); $ampm=date('a',$score['wintime']); print "<form action=\"$report_page?action=updatescore&conf=$confid\" method=\"post\">\n"; ?> <table width='100%' class='tbl-border'> <tr><td colspan='2' class='tbl1'><b>Status:</b> <?print $status;?></td></tr> <tr><td colspan='2' class='tbl1'><b>Date:</b> <?print $month?>/<?print $day?>/<?print $year?></td></tr> <tr><td colspan='2' class='tbl1'><b>Time:</b> <?print $hour?>:<?print $minute?> <?print $ampm?></td></tr> <tr><td class='tbl1'><b>Field:</b> <?print $field;?></td><td class='tbl1'><b>Field No:</b> <?print $field_no;?></div></td></tr> // Attempted to Change to remove the DROP DOWN Menu - UNSUCCESSFUL! <tr><td class='tbl1'><b>Home Team</b>: <?php $query2="SELECT s2010_teams.teamid, s2010_teams.teamname, s2010_divs.divname FROM s2010_teams, s2010_divs WHERE s2010_teams.active = 1 AND s2010_teams.teamdiv = s2010_divs.divid AND s2010_divs.conference = $confid ORDER BY divorder ASC, teamname ASC"; $result2=mysql_query($query2); while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "" . $teams['teamname'].""; } print "</td><td bgcolor='#FFFF00'><b>Score:</b> <input type=\"text\" name=\"rf\" size=\"2\" maxlength=\"2\" value=\"{$score['rf']}\" /></td></tr>\n"; ?> <tr><td colspan='2' align='center' bgcolor='#FFFF00'> <select name="winortie"> <option value="3" <?php if ($score['winortie'] == 3) { echo 'selected="selected"'; } ?> >Play - Scheduled </option> <option value="1" <?php if ($score['winortie'] == 1) { echo 'selected="selected"'; } ?> >Beat </option> <?php if ($forfeit) { print "<option value=\"2\" "; if ($score['winortie'] == 2) print "selected=\"selected\""; print ">Beat (by forfeit)</option>\n"; } ?> <?php if ($show_ties) { print "<option value=\"0\" "; if ($score['winortie'] == 0) print "selected=\"selected\""; print ">Tied</option>\n"; } ?> <option value="4" <?php if ($score['winortie'] == 4) { print "selected=\"selected\""; } ?> >Lost to </option> <?php if ($forfeit) { print "<option value=\"5\" "; if ($score['winortie'] == 5) print "selected=\"selected\""; print ">Lost to (by forfeit)</option>\n"; } ?> </select></td></tr> // Original version of Team Display in DROP DOWN MENU <tr><td class='tbl1'><b>Visiting Team:</b> <select name="loser"> <?php $query3="SELECT s2010_teams.teamid, s2010_teams.teamname, s2010_divs.divname FROM s2010_teams, s2010_divs WHERE s2010_teams.active=1 AND s2010_teams.teamdiv = s2010_divs.divid AND s2010_divs.conference = $confid ORDER BY divorder ASC, teamname ASC"; $result3=mysql_query($query3); while ($teams = mysql_fetch_array($result3, MYSQL_ASSOC)) { echo "<option value=\"{$teams['teamid']}\""; if ($teams['teamid'] == $score['loser']) { print " selected=\"selected\""; } print ">{$teams['teamname']}</option>\n"; } print "</select></td><td bgcolor='#FFFF00'><b>Score:</b> <input type=\"text\" name=\"ra\" size=\"2\" maxlength=\"2\" value=\"{$score['ra']}\" /></td></tr>\n"; ?> <tr><td colspan='2' class='tbl1'><b>Comments:</b> <input name="teamcomments" type="text" value="<?php print $teamcomments;?>" size="70"> <input type="hidden" name="winid" value=<?php print $winid;?>> </td></tr> <tr><td colspan='2' class='tbl1' align='center'><input type="submit" value="Update"></p> </form> <?php print "<form method=\"get\" action=\"$report_page\">\n"; print "<input type=\"hidden\" name=\"action\" value=\"mainview\" />\n"; print "<input type=\"hidden\" name=\"conf\" value=\"$confid\" />\n"; print "<input type=\"submit\" value=\"Cancel\"></td></tr></table></form>\n"; You can see my attempted change in Home Team display. Visiting Team display is not alterred and displays the drop down menu with the predetermined team selected. I am still getting a list of the Division Teams in Home Team echo and only want to echo the selected team in text display. Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920830 Share on other sites More sharing options...
mikesta707 Posted September 18, 2009 Share Posted September 18, 2009 try changing your prints to look like this <?php print $status; ?> instead of what you had. <?print $status;?> thats an invalid php tag Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920834 Share on other sites More sharing options...
hola hola Posted September 18, 2009 Author Share Posted September 18, 2009 I will update that, but that field is echoing properly. I am looking at updating Home Team and Visiting Team. Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920841 Share on other sites More sharing options...
DavidAM Posted September 18, 2009 Share Posted September 18, 2009 add an if statement inside the loop ? while ($teams = mysql_fetch_array($result2, MYSQL_ASSOC)) { if ($winid == $teams['teamid']) echo "" . $teams['teamname'].""; } although, I think I would just add AND teamid = $winid to the query rather than return and loop through a bunch of rows that are not used. Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920842 Share on other sites More sharing options...
hola hola Posted September 18, 2009 Author Share Posted September 18, 2009 GOT IT! I just had to change: if ($winid == $teams['teamid']) to: if ($teams['teamid'] == $score['winner']) and 'loser' for Visiting Team. THANKS! Quote Link to comment https://forums.phpfreaks.com/topic/174718-solved-print-record/#findComment-920847 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.