Jump to content

ed01

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by ed01

  1. What I'm trying to do is the following: Capture the latest date from any record in the table. Use that date to create a query to display all records of only that date. Here's what I have so far... SELECT hometeam, weekdate,day FROM sched_games WHERE day='Saturday' ORDER BY 'weekdate' DESC OUTPUT IS: hometeam weekdate day Euro 11/19/2011 Saturday Crusaders 11/19/2011 Saturday Cobras 11/26/2011 Saturday Titans 11/26/2011 Saturday Porto 9/24/2011 Saturday Titans 9/24/2011 Saturday Porto 9/15/2012 Saturday As you can see, the records are not being sorted by the weekdate. Seems like I need to convert the values in the weekdate column so that mysql recognizes them as dates first, and then maybe the sorting will work? Any help would be much appreciated. Thanks! Ed
  2. That may be, but I have a bigger problem. When I click the button to POST the submit-AddWeek form it will not even look at the following IF statement that asks it to compare POST 'schedule_template'. It always bypasses it entirely! And continues to output to the screen only "Query was emptyThe query was ." - UGH! See the code below that does NOT print out "testing". Is there a rule about not being able to capture an IF statement POST within ANOTHER IF statement POST?? Thanks again! // Check if the form has been submitted. if ( isset ($_POST['submit-AddWeek'])) { if (($_POST['sched_templates']) == 'sched_TestingOnly.htm') { // $query = include 'sched_TestingOnlyQuery1.php'; // $query = '$query = ' . '"' . $query . '"'; print "testing"; } /*$query = "INSERT INTO sched_boys (game_id, division, level, hometeam, awayteam, field, weekdate, day, time, comment, referee) VALUES ('NULL', '{$_POST['division'][0]}', '{$_POST['level'][0]}', '{$_POST['hometeam'][0]}', '{$_POST['awayteam'][0]}', '{$_POST['field'][0]}', '{$_POST['weekdate'][0]}', '{$_POST['day'][0]}', '{$_POST['time'][0]}', '{$_POST['comment'][0]}', '{$_POST['referee'][0]}' ), ('NULL', '{$_POST['division'][1]}', '{$_POST['level'][1]}', '{$_POST['hometeam'][1]}', '{$_POST['awayteam'][1]}', '{$_POST['field'][1]}', '{$_POST['weekdate'][1]}', '{$_POST['day'][1]}', '{$_POST['time'][1]}', '{$_POST['comment'][1]}', '{$_POST['referee'][1]}' )";*/ // Execute the query. if (@mysql_query ($query)) { mysql_close(); // End adding Registration to the database header ('Location: CMFSCregistration_reply.htm'); exit();
  3. Just to be clear; this script is still NOT WORKING . The output of the include file appears to create a complete insert query but it still isn't captured such that it can be used in the overall script. Bah! Thanks for any help!
  4. yes, I think I've finally got the right code to return the data from the include file. The content in my include file (sched_TestingOnlyQuery1.php) is as follows: <? return "INSERT INTO sched_boys (game_id, division, level, hometeam, awayteam, field, weekdate, day, time, comment, referee) VALUES ('NULL', '{$_POST['division'][0]}', '{$_POST['level'][0]}', '{$_POST['hometeam'][0]}', '{$_POST['awayteam'][0]}', '{$_POST['field'][0]}', '{$_POST['weekdate'][0]}', '{$_POST['day'][0]}', '{$_POST['time'][0]}', '{$_POST['comment'][0]}', '{$_POST['referee'][0]}' ), ('NULL', '{$_POST['division'][1]}', '{$_POST['level'][1]}', '{$_POST['hometeam'][1]}', '{$_POST['awayteam'][1]}', '{$_POST['field'][1]}', '{$_POST['weekdate'][1]}', '{$_POST['day'][1]}', '{$_POST['time'][1]}', '{$_POST['comment'][1]}', '{$_POST['referee'][1]}' )"; ?> Now, as requested, below is my script code: Note; I've commented out the INSERT query, it is there for testing. Note: I suspect there may be a problem with the nested "if" statements under the comment "// Check if the form has been submitted." Thanks. <?php // Turn on output buffering ob_start(); // - sched_boys.php // This page allows login to view the Boys Schedule // Address error handing. ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>CREATE SCHEDULE</title> </head> <body> <?php // is someone logged in? if (isset($_SESSION['loggedin'])) { require_once 'db.php'; if (!($connection = @ mysql_connect($hostname, $username, $password))) showerror(); if (!mysql_select_db($databasename, $connection)) showerror(); // Check if the form has been submitted. if ( isset ($_POST['submit-AddWeek'])) { if (($_POST['sched_templates']) == "sched_TestingOnly.htm") { $query = include 'sched_TestingOnlyQuery1.php'; $query = '$query = ' . '"' . $query . '"'; } //$query = "INSERT INTO sched_boys (game_id, division, level, hometeam, awayteam, field, weekdate, day, time, comment, referee) VALUES ('NULL', '{$_POST['division'][0]}', '{$_POST['level'][0]}', '{$_POST['hometeam'][0]}', '{$_POST['awayteam'][0]}', '{$_POST['field'][0]}', '{$_POST['weekdate'][0]}', '{$_POST['day'][0]}', '{$_POST['time'][0]}', '{$_POST['comment'][0]}', '{$_POST['referee'][0]}' ), ('NULL', '{$_POST['division'][1]}', '{$_POST['level'][1]}', '{$_POST['hometeam'][1]}', '{$_POST['awayteam'][1]}', '{$_POST['field'][1]}', '{$_POST['weekdate'][1]}', '{$_POST['day'][1]}', '{$_POST['time'][1]}', '{$_POST['comment'][1]}', '{$_POST['referee'][1]}' )";*/ // Execute the query. if (@mysql_query ($query)) { mysql_close(); // End adding Registration to the database header ('Location: CMFSCregistration_reply.htm'); exit(); } else { /*print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";*/ print "<p><b>Sorry, your entry could not be entered. This is most often due to punctuation, particularly single and double quotation marks. Please remove punctuation in the form and try again.</b></p><p>" . mysql_error() . "The query was $query.</p>"; // print $try; } // end else } else { // end if POST submit-AddWeek - LINE 36 // $month = ($_POST['month']); ?> <!-- DISPLAY THE 'CHOOSE A DATE' FORM --> <div align=center> <form id="form2" name="setdate-template" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"> <table summary="choose a date" width="800" align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0"> <tr><td align="center"><h2>Create Schedule for New Week (boys or girls)</h2></td></tr> <tr><td align="center"><strong>Choose a date for the new schedule: </strong> <?PHP // insert require file to build menus for dates require_once("date_time.php"); // print out months for selection menu print 'month: '; print '<select name="month">'; print $month_; // call up the array from the require file print '</select> '; // print out day for selection menu print ' day: '; print '<select name="day">'; print $day_; // call up the array from the require file print '</select> '; // print out year for selection menu print '<select name="year">'; print $year_; // call up the array from the require file print '</select> '; $month = ($_POST['month']); if ($month == "January") {$month = 1;} if ($month == "February") {$month = 2;} if ($month == "March") {$month = 3;} if ($month == "April") {$month = 4;} if ($month == "May") {$month = 5;} if ($month == "June") {$month = 6;} if ($month == "July") {$month = 7;} if ($month == "August") {$month = 8;} if ($month == "September") {$month = 9;} if ($month == "October") {$month = 10;} if ($month == "November") {$month = 11;} if ($month == "December") {$month = 12;} $day = ($_POST['day']); $year = ($_POST['year']); $timestamp = mktime (0, 0, 0, (int)$month, (int)$day, (int)$year); print '<br />'."You must choose and set a date for the new schedule before adding a week".'<br />'; ?> </td> </tr> <tr><td align="center">You have chosen to create a schedule for the following date: <font color="#FF0000"><? echo date ('l, n/j/Y', $timestamp); ?></font></td></tr> </table> <br /> <?php $weekday = date ('l', $timestamp); $weekdate = date ('n/j/Y', $timestamp); ?> <!-- DISPLAY FORM TO CALL UP A SCHEDULE TEMPLATE --> <?php // create list of years for sticky forms $templatearr = array( "sched_boysTemplate1.htm", "sched_boysTemplate2.htm", "sched_girlsTemplate1.htm", "sched_girlsTemplate2.htm", "sched_TestingOnly.htm" ); //$template_ = ''; foreach($templatearr as $key) { $template_ .= "<option value=\"$key\"".($_POST['sched_templates'] == $key ? " selected=\"selected\"" : "").">{$key}</option>\n"; } if (strpos($template_, "selected=")) { $template_ = "<option value=\"\">choose</option>\n{$template_}"; } else { $template_ = "<option value=\"\" selected=\"selected\">choose</option>\n{$template_}"; } ?> <?php // display selection menu print 'Choose a template to import: '; print '<select name="sched_templates">' . "echo $template_;" . '</select> '; // print $template_; // call up the array // print '</select> '; ?> <!-- <input type="submit" name="form1" id="form-choosetemplate" value="Choose a template" />--> <input type="submit" name="setdate-template" id="form2" value="Lock in Date and working template now" /> </form> </div> <br /> <!-- DISPLAY THE 'CREATE A NEW WEEK' FORM AND RECORDS --> <form name="submit-AddWeek" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" > <table summary="choose a date" width="700" align="center" cellpadding="3" cellspacing="1" border="0" > <tr> <td></td> <td>DIV</td> <td>LVL</td> <td>HOME TEAM</td> <td>AWAY TEAM</td> <td>FIELD</td> <td></td> <td></td> <td>TIME</td> <td>COMMENT</td> <td></td> </tr> <? if (($_POST['sched_templates']) == "") { } else { include "{$_POST['sched_templates']}"; } ?> <td colspan="11"> <div align="left"> <p align="center"> <? if ( isset ($_POST['setdate-template'])) { ?> <? //if ($week == 0) { //print $week; //$weekerror = "You must choose a new week before adding a week"; //print $weekerror; //print '<input type="submit" name="sub_mit" value="Add week" />'. "{$weekerror}"; //print $weekerror; //} else { print '<input type="submit" name="submit-AddWeek" value="Add week now" />'; //} ?> <? } else { print "You must choose a date first before the Submit button is available here"; } ?> </p> </div> </td> </tr> </table> </form><!-- close submit-AddWeek form --> <? } // end if isset POST submit // end if isset SESSION } else { // Basic HTML formatting stuff. // Check if the form has been submitted. if ( isset ($_POST['submit-login'])) { // Handle the form. if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ) { if ( ($_POST['username'] == 'removed') && ($_POST['password'] == 'removed') ) { // Okay. // Do session stuff $_SESSION['username'] = 'removed'; $_SESSION['password'] = 'removed'; $_SESSION['loggedin'] = time(); // redirect logged in user back to this page header("Location: {$_SERVER['PHP_SELF']}"); exit(); } else { // Not okay. print '<p>The submitted username and password do not match those on file!<br />Go back and try again.</p>'; } } else { // Forgot a field. print '<p>Please make sure you enter both a username and a password!<br />Go back and try again.</p>'; } } else { // Basic HTML formatting stuff. print '<h2>Field Scheduler Login</h2> <p>Please enter your User Name and Password.</p>'; // Display the form. print '<form action="sched_create.php" method="post"><p> Username: <input type="text" name="username" size="20" /><br /> Password: <input type="password" name="password" size="20" /><br /> <input type="submit" name="submit-login" value="Log In!" /></p> </form>'; } // end else } ?> </body> </html> <?php // Turn off output buffering ob_end_flush(); ?>
  5. Sorry but I've already messed around with my code too much for it to likely be of any additional help. The code above is the jist of what I'm trying to do. When I use INCLUDE (in my second example above ie. $query = include 'sched_TestingOnlyQuery1.php'; ) it just puts the code from the include file onto the browser screen when I complete my script. Instead what I'm trying to do is APPLY it into the INSERT query statement as a variable so my script can use it to INSERT into my table. I'm baffled why this isn't possible. As always anyone's help is greatly appreciated!!! Ed
  6. Can't get it working - looks impossible .... :'( Help anyone?... :'(
  7. Thank you for the suggestion!! OK, I tried that ... if (($_POST['sched_templates']) == "sched_TestingOnly.htm") { $query = include 'sched_TestingOnlyQuery1.php'; return $query; } however the script ends with an error and displays "Query was emptyThe query was ." Below is the content of the new php file and if I test with just that code it posts perfectly to my table, so all other parts are working OK, it's just capturing and applying into the query statement that it doesn't like to do. Syntax problems? $query = "INSERT INTO sched_boys (game_id, division, level, hometeam, awayteam, field, weekdate, day, time, comment, referee) VALUES ('NULL', '{$_POST['division'][0]}', '{$_POST['level'][0]}', '{$_POST['hometeam'][0]}', '{$_POST['awayteam'][0]}', '{$_POST['field'][0]}', '{$_POST['weekdate'][0]}', '{$_POST['day'][0]}', '{$_POST['time'][0]}', '{$_POST['comment'][0]}', '{$_POST['referee'][0]}' ), ('NULL', '{$_POST['division'][1]}', '{$_POST['level'][1]}', '{$_POST['hometeam'][1]}', '{$_POST['awayteam'][1]}', '{$_POST['field'][1]}', '{$_POST['weekdate'][1]}', '{$_POST['day'][1]}', '{$_POST['time'][1]}', '{$_POST['comment'][1]}', '{$_POST['referee'][1]}' )"; Again - thanks so much for any help! Ed
  8. I'm trying to create a INSERT query statement that makes use of the content of 'include' files. When I call up the include it simply echos it to the screen but I can't seem to capture the text string and actually make it function as part of the query. I've tried setting the include as a variable but again it only outputs to the screen. Help please! Here's a portion of the code... if (($_POST['sched_templates']) == "sched_TestingOnly.htm") { $query = include 'sched_TestingOnlyQuery1.htm'; } if (@mysql_query ($query)) { mysql_close(); // End adding Registration to the database header ('Location: redirectfile.htm'); exit(); } else { print "<p><b>Sorry, your entry could not be entered. }
  9. Hey thanks man - your suggestion and example really helped me out! Great forum - good quick results. Yeah, I was concerned about all the code. Will not do that again. Best regards Ed
  10. <?php // Turn on output buffering ob_start(); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/MountainWFCtemplate.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Mountain FC - Game Report 2010</title> <!-- InstanceEndEditable --> <link rel="stylesheet" rev="stylesheet" href="CSS/mountainWFC.css" type="text/css" media="screen" charset="utf-8" /> <link rel="stylesheet" rev="stylesheet" href="CSS/tabmenu.css" type="text/css" media="screen" charset="utf-8" /> <script src="CSS/tabmenu.js" type="text/javascript" language="Javascript1.2" charset="utf-8"></script> </head> <body background="newlook2008/nettingbackground.gif"> <div id="header"></div> <!--close header contains top banner --> <div id="container"> <div id="mainMenu"> <a class="inactiveMenuItem" style="left: 90px;" id="mainMenuItem1" href="index.htm">home</a> <a class="inactiveMenuItem" style="left: 160px;" id="mainMenuItem2" href="#">U12B</a> <a class="inactiveMenuItem" style="left: 160px;" id="mainMenuItem3" href="#">U13B</a> <a class="inactiveMenuItem" style="left: 215px;" id="mainMenuItem4" href="#">U14B</a> <a class="inactiveMenuItem" style="left: 270px;" id="mainMenuItem5" href="#">U15B</a> <a class="inactiveMenuItem" style="left: 325px;" id="mainMenuItem6" href="#">U16B</a> <a class="inactiveMenuItem" style="left: 380px;" id="mainMenuItem7" href="#">U12G</a> <a class="inactiveMenuItem" style="left: 380px;" id="mainMenuItem8" href="#">U13G</a> <a class="inactiveMenuItem" style="left: 435px;" id="mainMenuItem9" href="#">U14G</a> <a class="inactiveMenuItem" style="left: 490px;" id="mainMenuItem10" href="#">U15G</a> <a class="inactiveMenuItem" style="left: 545px;" id="mainMenuItem11" href="#">U16G</a> <a class="inactiveMenuItem" style="left: 600px;" id="mainMenuItem12" href="coaches.htm">coaches</a> <a class="inactiveMenuItem" style="left: 655px;" id="mainMenuItem13" href="contacts.htm">contacts</a> <a class="activeMenuItem" style="left: 710px;" id="mainMenuItem14" href="http://supery.uslsoccer.com/scripts/runisa.dll?M2.65846:gp:1376787602.2009:72016+Elements/Display+E+18235+Letter/Display/+A++9386895">fields</a></div> <!--close mainMenu --> <div id="submenu"> <div style="padding-left: 30px; position: static; display: none;" id="submenu_1"> </div> <div style="padding-left: 30px; position: static; display: none;" id="submenu_2"> <a href="U12Broster.htm">Roster</a> | <a href="U12Bschedule.htm">Schedule</a> | <a href="gamereportsU12B.php">Game Reports</a> </div> <div style="padding-left: 50px; position: static; display: none;" id="submenu_3"> <a href="http://supery.uslsoccer.com/teams/2010/roster/20538126.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/20538126.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508671.html" target="_blank">Standings</a> | <a href="gamereportsU13B.php">Game Reports</a> </div> <div style="padding-left: 105px; position: static; display: none;" id="submenu_4"> <a href="http://supery.uslsoccer.com/teams/2010/roster/14865877.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/14865877.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508672.html" target="_blank">Standings</a> | <a href="gamereportsU14B.php">Game Reports</a> </div> <div style="padding-left: 160px; position: static; display: none;" id="submenu_5"> <a href="http://supery.uslsoccer.com/teams/2010/roster/9388182.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/9388182.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508673.html" target="_blank">Standings</a> | <a href="gamereportsU15B.php">Game Reports</a> </div> <div style="padding-left: 215px; position: static; display: none;" id="submenu_6"> <a href="http://supery.uslsoccer.com/teams/2010/roster/6602006.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/6602006.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508674.html" target="_blank">Standings</a> | <a href="gamereportsU16B.php">Game Reports</a> </div> <div style="padding-left: 270px; position: static; display: none;" id="submenu_7"> <a href="U12Groster.htm">Roster</a> | <a href="U12Gschedule.htm">Schedule</a> | <a href="gamereportsU12G.php">Game Reports</a> </div> <div style="padding-left: 325px; position: static; display: none;" id="submenu_8"> <a href="http://supery.uslsoccer.com/teams/2010/roster/20538156.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/20538156.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508724.html" target="_blank">Standings</a> | <a href="gamereportsU13G.php">Game Reports</a> </div> <div style="padding-left: 380px; position: static; display: none;" id="submenu_9"> <a href="http://supery.uslsoccer.com/teams/2010/roster/14865998.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/14865998.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508725.html" target="_blank">Standings</a> | <a href="gamereportsU14G.php">Game Reports</a> </div> <div style="padding-left: 435px; position: static; display: none;" id="submenu_10"> <a href="http://supery.uslsoccer.com/teams/2010/roster/9388183.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/9388183.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508726.html" target="_blank">Standings</a> | <a href="gamereportsU15G.php">Game Reports</a> </div> <div style="padding-left: 490px; position: static; display: none;" id="submenu_11"> <a href="http://supery.uslsoccer.com/teams/2010/roster/6602007.html" target="_blank">Roster</a> | <a href="http://supery.uslsoccer.com/teams/2010/6602007.html" target="_blank">Schedule</a> | <a href="http://supery.uslsoccer.com/schedules/2010/20508727.html" target="_blank">Standings</a> | <a href="gamereportsU16G.php">Game Reports</a> </div> <div style="padding-left: 545px; position: static; display: none;" id="submenu_12"> </div> <div style="padding-left: 600px; position: static; display: none;" id="submenu_13"> </div> <div style="padding-left: 655px; position: static; display: none;" id="submenu_14"> </div> </div><!--close submenu --> <div id="rightColumn"> <div id="date"> <script language=JavaScript> var now = new Date(); var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); var monNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); document.write(monNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear()); </script> </div><!-- close date --> <br /> <div id="searchbox"> <!-- Google CSE Search Box Begins --> <form action="http://www.mountainwfc.ca/searchresults.htm" id="searchbox_006277235729731948122:8aawxadozfc"> <input type="hidden" name="cx" value="006277235729731948122:8aawxadozfc" /> <input type="hidden" name="cof" value="FORID:11" /> <input type="text" name="q" size="19" /> <input type="submit" name="sa" value="Site Search" /> </form> <!-- Google CSE Search Box Ends --> <div id="rightColumnRow1"> <div align="center" class="highlight"> <p><strong><a href="gallery.htm" class="highlight">Photo Gallery</a></strong></p> <p><strong><a href="practiceschedule.htm">Practice Schedule</a> </strong></p> <p><strong><a href="forms.htm" class="highlight">Forms</a> </strong></p> <p><a href="https://ssl.demosphere.com/72957/" target="_blank"><strong>Register Here</strong></a></p> <p><strong><a href="archives.htm" class="highlight">Archives</a> </strong></p> </div> <div align="center"><a href="http://www.whitecapsfc.com" target="_blank"><img src="newlook2008/whitecapsfc.gif" alt="whitecapsfc" border="0" /></a></div> </div> <div id="rightColumnRow2"> <div align="center"><a href="http://www.whitecapsfc.com/youth/professionaldevelopment/regionalleaguesupery/" target="_blank"><img src="newlook2008/superYleague.gif" alt="superYleague" width="104" height="107" border="0" /></a></div> </div> <div id="rightColumnRow2"> <div align="center"><a href="http://www.bcsoccer.net/bcsa/" target="_blank"><img src="newlook2008/pageLogo.jpg" alt="BC Soccer" width="140" height="116" border="0" /></a></div> </div> </div> </div><!--close rightColumn --> <!-- InstanceBeginEditable name="dynamic" --> <!-- InstanceEndEditable --> <!--close dynamic_content --> <!-- InstanceBeginEditable name="content" --> <div id="content"> <?php // - MountainFCgamereports2010_WORKING // This is the MountainFC game reports entry page. if (isset($_SESSION['loggedin'])) { // Check if the form has been submitted. if ( isset ($_POST['submit'])) { $age_level = $_POST['age_level']; $age_level = $_POST['age_level']; $opposition = htmlentities ($_POST['opposition']); // prevents delete of characters following a double quote $opposition = stripslashes ($opposition); // removes unsightly slashes $game_month = htmlentities ($_POST['game_month']); $game_month = stripslashes ($game_month); $game_day = htmlentities ($_POST['game_day']); $game_day = stripslashes ($game_day); $location = htmlentities ($_POST['location']); $location = stripslashes ($location); $weather = htmlentities ($_POST['weather']); $weather = stripslashes ($weather); $mountainfcscore = $_POST['mountainfcscore']; $oppositionscore = $_POST['oppositionscore']; $halftimescore = htmlentities ($_POST['halftimescore']); $halftimescore = stripslashes ($halftimescore); $game_details = htmlentities ($_POST['game_details']); $game_details = stripslashes ($game_details); $scorer1 = htmlentities ($_POST['scorer1']); $scorer1 = stripslashes ($scorer1); $scorer2 = htmlentities ($_POST['scorer2']); $scorer2 = stripslashes ($scorer2); $scorer3 = htmlentities ($_POST['scorer3']); $scorer3 = stripslashes ($scorer3); $scorer4 = htmlentities ($_POST['scorer4']); $scorer4 = stripslashes ($scorer4); $scorer5 = htmlentities ($_POST['scorer5']); $scorer5 = stripslashes ($scorer5); $scorer6 = htmlentities ($_POST['scorer6']); $scorer6 = stripslashes ($scorer6); $scorer7 = htmlentities ($_POST['scorer7']); $scorer7 = stripslashes ($scorer7); $scorer8 = htmlentities ($_POST['scorer8']); $scorer8 = stripslashes ($scorer8); $scorer9 = htmlentities ($_POST['scorer9']); $scorer9 = stripslashes ($scorer9); $assist1_1 = htmlentities ($_POST['assist1_1']); // 2_1 indicates the one who first assisted the second goal $assist1_1 = stripslashes ($assist1_1); $assist2_1 = htmlentities ($_POST['assist2_1']); // 2_1 indicates the one who first assisted the second goal $assist2_1 = stripslashes ($assist2_1); $assist3_1 = htmlentities ($_POST['assist3_1']); $assist3_1 = stripslashes ($assist3_1); $assist4_1 = htmlentities ($_POST['assist4_1']); $assist4_1 = stripslashes ($assist4_1); $assist5_1 = htmlentities ($_POST['assist5_1']); $assist5_1 = stripslashes ($assist5_1); $assist6_1 = htmlentities ($_POST['assist6_1']); $assist6_1 = stripslashes ($assist6_1); $assist7_1 = htmlentities ($_POST['assist7_1']); $assist7_1 = stripslashes ($assist7_1); $assist8_1 = htmlentities ($_POST['assist8_1']); $assist8_1 = stripslashes ($assist8_1); $assist9_1 = htmlentities ($_POST['assist9_1']); $assist9_1 = stripslashes ($assist9_1); $assist1_2 = htmlentities ($_POST['assist1_2']); $assist1_2 = stripslashes ($assist1_2); $assist2_2 = htmlentities ($_POST['assist2_2']); $assist2_2 = stripslashes ($assist2_2); $assist3_2 = htmlentities ($_POST['assist3_2']); $assist3_2 = stripslashes ($assist3_2); $assist4_2 = htmlentities ($_POST['assist4_2']); $assist4_2 = stripslashes ($assist4_2); $assist5_2 = htmlentities ($_POST['assist5_2']); $assist5_2 = stripslashes ($assist5_2); $assist6_2 = htmlentities ($_POST['assist6_2']); $assist6_2 = stripslashes ($assist6_2); $assist7_2 = htmlentities ($_POST['assist7_2']); $assist7_2 = stripslashes ($assist7_2); $assist8_2 = htmlentities ($_POST['assist8_2']); $assist8_2 = stripslashes ($assist8_2); $assist9_2 = htmlentities ($_POST['assist9_2']); $assist9_2 = stripslashes ($assist9_2); // Check for each value. $err_age_level = (empty($age_level) ? '<b><font color="#FF0000">Please select the Age & Level</font></b>' : ''); $err_opposition = (empty($opposition) ? '<b><font color="#FF0000">Please enter the opposition team name</font></b>' : ''); $err_game_month = (empty($game_month) ? '<b><font color="#FF0000">Please select the month</font></b>' : ''); $err_game_day = (empty($game_day) ? '<b><font color="#FF0000">Please select the game date</font></b>' : ''); $err_mountainfcscore = (empty($mountainfcscore) ? '<b><font color="#FF0000">Please enter MountainFC score</font></b>' : ''); $err_oppositionscore = (empty($oppositionscore) ? '<b><font color="#FF0000">Please enter Oppositions score</font></b>' : ''); $err_submittor = (empty($submittor) ? '<b><font color="#FF0000">Please enter your initials</font></b>' : ''); // no error messages if (empty($err_age_level) && empty($err_opposition) && empty($err_game_month) && empty($err_game_day) && empty($err_mountainfcscore) && empty($err_oppositionscore) && empty($err_submittor)) { // if (!$problem) // If there weren't any problems... // Add registration to the database. // Connect and select. $dbc = @mysql_connect ('xx', 'xx', 'xx') or die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>'); $x = @mysql_select_db ('xx') or die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>'); require ('REQtimestampPT.php'); // Define the query. $query = "INSERT INTO MountainFCgamereports2010_WORKING (game_id, age_level, opposition, game_month, game_day, location, weather, mountainfcscore, oppositionscore, halftimescore, game_details, scorer1, assist1_1, assist1_2, scorer2, assist2_1, assist2_2, scorer3, assist3_1, assist3_2, scorer4, assist4_1, assist4_2, scorer5, assist5_1, assist5_2, scorer6, assist6_1, assist6_2, scorer7, assist7_1, assist7_2, scorer8, assist8_1, assist8_2, scorer9, assist9_1, assist9_2, submittor, date_entered) VALUES (0, '".mysql_real_escape_string($age_level)."', '".mysql_real_escape_string($opposition)."', '".mysql_real_escape_string($game_month)."', '".mysql_real_escape_string($game_day)."', '".mysql_real_escape_string($location)."', '".mysql_real_escape_string($weather)."', '".mysql_real_escape_string($mountainfcscore)."', '".mysql_real_escape_string($oppositionscore)."', '".mysql_real_escape_string($halftimescore)."', '".mysql_real_escape_string($game_details)."', '".mysql_real_escape_string($scorer1)."', '".mysql_real_escape_string($assist1_1)."', '".mysql_real_escape_string($assist1_2)."', '".mysql_real_escape_string($scorer2)."', '".mysql_real_escape_string($assist2_1)."', '".mysql_real_escape_string($assist2_2)."', '".mysql_real_escape_string($scorer3)."', '".mysql_real_escape_string($assist3_1)."', '".mysql_real_escape_string($assist3_2)."', '".mysql_real_escape_string($scorer4)."', '".mysql_real_escape_string($assist4_1)."', '".mysql_real_escape_string($assist4_2)."', '".mysql_real_escape_string($scorer5)."', '".mysql_real_escape_string($assist5_1)."', '".mysql_real_escape_string($assist5_2)."', '".mysql_real_escape_string($scorer6)."', '".mysql_real_escape_string($assist6_1)."', '".mysql_real_escape_string($assist6_2)."', '".mysql_real_escape_string($scorer7)."', '".mysql_real_escape_string($assist7_1)."', '".mysql_real_escape_string($assist7_2)."', '".mysql_real_escape_string($scorer8)."', '".mysql_real_escape_string($assist8_1)."', '".mysql_real_escape_string($assist8_2)."', '".mysql_real_escape_string($scorer9)."', '".mysql_real_escape_string($assist9_1)."', '".mysql_real_escape_string($assist9_2)."', '".mysql_real_escape_string($submittor)."', '$registr_time')"; // Execute the query. if (@mysql_query ($query)) { //mysql_query("INSERT INTO mytable (product) values ('kossu')"); print '<b>'; printf("New Game Report id %d\n", mysql_insert_id()); $last_record_id = (mysql_insert_id()); //print $last_record_id; print 'has been sent for approval on '; print $registr_time; print '</b>'; mysql_close(); // End adding Registration to the database /*header ('Location: MountainFC_Y_League_EvaluationSignUpReply.htm');*/ print '<font color="#FF0000" size="+1"><p><b>Please do not hit Submit again without first entering new game report information, or click <a href="http://www.mountainfc.ca/closesession_logout.php">HERE to logout</a></b></p></font>'; } else { print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } $link = "http://www.mountainfc.ca/gamereports_APPROVAL_WORKING.php?username=xxxxx&password=xxxxx&game_id=$last_record_id"; $email = 'foucherfamily@shaw.ca'; $body="A new game report has been submitted that requires approval.\nPlease click on the following link to open the pending report.\n $link , \n\n\n\n\nNote: this is an automated notification, do not reply to this email"; $headers="From: MountainFC" . "\r\n" ; //mail ($email, 'Game report submitted for approval' , $body, 'From: MountainFC'); mail ($email, 'Game report submitted for approval' , $body, $headers); } } else { // default to blank values $age_level = ''; $opposition = ''; $game_month = ''; $game_day = ''; $weather = ''; $mountainfcscore = ''; $oppositionscore = ''; $halftimescore = ''; $game_details = ''; $scorer1 = ''; $assist1_1 = ''; $assist1_2 = ''; $scorer2 = ''; $assist2_1 = ''; $assist2_2 = ''; $scorer3 = ''; $assist3_1 = ''; $assist3_2 = ''; $scorer4 = ''; $assist4_1 = ''; $assist4_2 = ''; $scorer5 = ''; $assist5_1 = ''; $assist5_2 = ''; $scorer6 = ''; $assist6_1 = ''; $assist6_2 = ''; $scorer7 = ''; $assist7_1 = ''; $assist7_2 = ''; $scorer8 = ''; $assist8_1 = ''; $assist8_2 = ''; $scorer9 = ''; $assist9_1 = ''; $assist9_2 = ''; // default; no error messages $err_age_level = ''; $err_opposition = ''; $err_game_month = ''; $err_game_day = ''; $err_mountainfcscore = ''; $err_oppositionscore = ''; $err_submittor = ''; } // Display the form. // create list of age_level for sticky forms $age_levelarray = array( "U12 GIRLS", "U13 GIRLS", "U14 GIRLS", "U15 GIRLS", "U16 GIRLS", "U12 BOYS", "U13 BOYS", "U14 BOYS", "U15 BOYS", "U16 BOYS" ); foreach($age_levelarray as $key) { $age_LEVELS .= "<option value=\"$key\"".($age_level == $key ? " selected=\"selected\"" : "").">{$key}</option>\n"; } if (strpos($age_LEVELS, "selected=")) { $age_LEVELS = "<option value=\"\">choose</option>\n{$age_LEVELS}"; } else { $age_LEVELS = "<option value=\"\" selected=\"selected\">choose</option>\n{$age_LEVELS}"; } // create list of game_month for sticky forms $game_montharray = array( "May", "June", "July", "August" ); foreach($game_montharray as $key) { $game_MONTHS .= "<option value=\"$key\"".($game_month == $key ? " selected=\"selected\"" : "").">{$key}</option>\n"; } if (strpos($game_MONTHS, "selected=")) { $game_MONTHS = "<option value=\"\">month</option>\n{$game_MONTHS}"; } else { $game_MONTHS = "<option value=\"\" selected=\"selected\">month</option>\n{$game_MONTHS}"; } // create list of game_day for sticky forms $game_dayarray = array( "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th", "31st" ); foreach($game_dayarray as $key) { $game_DAYS .= "<option value=\"$key\"".($game_day == $key ? " selected=\"selected\"" : "").">{$key}</option>\n"; } if (strpos($game_DAYS, "selected=")) { $game_DAYS = "<option value=\"\">day</option>\n{$game_DAYS}"; } else { $game_DAYS = "<option value=\"\" selected=\"selected\">day</option>\n{$game_DAYS}"; } //$positions = ''; /*foreach($positionarr as $key) { $positions .= "<option value=\"$key\"".($position_choice_1 == $key ? " selected=\"selected\"" : "").">{$key}</option>\n"; } if (strpos($positions, "selected=")) { $positions = "<option value=\"\">choose</option>\n{$positions}"; } else { $positions = "<option value=\"\" selected=\"selected\">choose</option>\n{$positions}"; }*/ /*<select name="game_day"> <option value="choose day">Monday</option> <option value="mon">Tuesday</option> <option value="tues">Wednesday</option> </select>*/ ?> <!--DISPLAY FORM --> <table width="97%" border="0" cellpadding="10" cellspacing="1" bgcolor="#ffffff"> <tr> <td colspan="4"><font color="#003399" size="4"><center> <strong>MOUNTAIN Y-LEAGUE GAME REPORT</strong> </center></font> <center> for 2010 season </center> </td> </tr> <tr> <td colspan="4"><font size="-2">* These fields are required.</font> </td> </tr> <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"><font size="-2"></font> <table width="97%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000"> <tr bordercolor="#000000"> <td style="background-color:#cc0033" colspan="4"><div align="center"><font color="#FFFFFF"><strong>GAME REPORT</strong></font></div></td> </tr> <tr bordercolor="#000000"> <td>Age Level *</td> <td colspan="3"><select name="age_level"><? echo $age_LEVELS; ?></select> <? echo $err_age_level; ?></td> </tr> <tr bordercolor="#000000"> <td>Name of opponent * </td> <td colspan="3"><input type="text" name="opposition" size="40" value="<? echo $opposition; ?>" /> <? echo $err_opposition; ?></td> </tr> <tr bordercolor="#000000"> <td>Game Date * </td> <td colspan="3"><select name="game_month"><? echo $game_MONTHS; ?></select> <? echo $err_game_month; ?> <select name="game_day"><? echo $game_DAYS; ?></select> <? echo $err_game_day; ?> </td> </tr> <tr bordercolor="#000000"> <td>Location</td> <td colspan="3"><input type="text" name="location" size="40" value="<? echo $location; ?>" /></td> </tr> <tr bordercolor="#000000"> <td>Weather, field conditions </td> <td colspan="3"><input type="text" name="weather" size="40" value="<? echo $weather; ?>" /></td> </tr> <tr bordercolor="#000000"> <td>Mountain FC score * </td> <td colspan="3"><input type="text" name="mountainfcscore" size="5" value="<? echo $mountainfcscore; ?>" /> <? echo $err_mountainfcscore; ?></td> </tr> <tr bordercolor="#000000"> <td>Opposition score * </td> <td colspan="3"><input type="text" name="oppositionscore" size="5" value="<? echo $oppositionscore; ?>" /> <? echo $err_oppositionscore; ?></td> </tr> <tr bordercolor="#000000"> <td>Half-time score<br />(mtn:oppos; ie 2:1)</td> <td colspan="3"><input type="text" name="halftimescore" size="5" value="<? echo $halftimescore; ?>" /></td> </tr> <tr bordercolor="#000000"> <td>Game details</td> <td colspan="3"><textarea name="game_details" cols="60" rows="6"><? echo $game_details; ?></textarea></td> </tr> <tr bordercolor="#000000"> <td> </td> <td>Scorer name</td> <td>Assist (first)</td> <td>Assist (second)</td> </tr> <tr bordercolor="#000000"> <td align="right">Goal #1</td> <td><input type="text" name="scorer1" size="20" value="<? echo $scorer1; ?>" /> <td><input type="text" name="assist1_1" size="20" value="<? echo $assist1_1; ?>" /> <td><input type="text" name="assist1_2" size="20" value="<? echo $assist1_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #2</td> <td><input type="text" name="scorer2" size="20" value="<? echo $scorer2; ?>" /> <td><input type="text" name="assist2_1" size="20" value="<? echo $assist2_1; ?>" /> <td><input type="text" name="assist2_2" size="20" value="<? echo $assist2_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #3</td> <td><input type="text" name="scorer3" size="20" value="<? echo $scorer3; ?>" /> <td><input type="text" name="assist3_1" size="20" value="<? echo $assist3_1; ?>" /> <td><input type="text" name="assist3_2" size="20" value="<? echo $assist3_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #4</td> <td><input type="text" name="scorer4" size="20" value="<? echo $scorer4; ?>" /> <td><input type="text" name="assist4_1" size="20" value="<? echo $assist4_1; ?>" /> <td><input type="text" name="assist4_2" size="20" value="<? echo $assist4_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #5</td> <td><input type="text" name="scorer5" size="20" value="<? echo $scorer5; ?>" /> <td><input type="text" name="assist5_1" size="20" value="<? echo $assist5_1; ?>" /> <td><input type="text" name="assist5_2" size="20" value="<? echo $assist5_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #6</td> <td><input type="text" name="scorer6" size="20" value="<? echo $scorer6; ?>" /> <td><input type="text" name="assist6_1" size="20" value="<? echo $assist6_1; ?>" /> <td><input type="text" name="assist6_2" size="20" value="<? echo $assist6_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #7</td> <td><input type="text" name="scorer7" size="20" value="<? echo $scorer7; ?>" /> <td><input type="text" name="assist7_1" size="20" value="<? echo $assist7_1; ?>" /> <td><input type="text" name="assist7_2" size="20" value="<? echo $assist7_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #8</td> <td><input type="text" name="scorer8" size="20" value="<? echo $scorer8; ?>" /> <td><input type="text" name="assist8_1" size="20" value="<? echo $assist8_1; ?>" /> <td><input type="text" name="assist8_2" size="20" value="<? echo $assist8_2; ?>" /> </tr> <tr bordercolor="#000000"> <td align="right">Goal #9</td> <td><input type="text" name="scorer9" size="20" value="<? echo $scorer9; ?>" /> <td><input type="text" name="assist9_1" size="20" value="<? echo $assist9_1; ?>" /> <td><input type="text" name="assist9_2" size="20" value="<? echo $assist9_2; ?>" /> </tr> <tr bordercolor="#000000"> <td>Initials of Submittor *</td> <td colspan="3"><input type="text" name="submittor" size="5" value="<? echo $submittor; ?>" /> <? echo $err_submittor; ?></td> </tr> <tr bordercolor="#000000"> <td colspan="4"> <div align="left"> <p align="center"> <input type="submit" name="submit" value="Submit for Approval" /> <!--<input type="reset" value="Clear form" />--> <!-- upon submit, would like form to clear of its values --> </p> </div> </td> </tr> </table> </form> </tr></td> </table> <?php // end if isset SESSION } else { // Basic HTML formatting stuff. // Check if the form has been submitted. if ( isset ($_POST['submit'])) { // Handle the form. if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ) { if ( ($_POST['username'] == 'xxxxxxx') && ($_POST['password'] == 'xxxxxxx') ) { // Okay. // Do session stuff $_SESSION['username'] = 'xxxxxxx'; $_SESSION['password'] = 'xxxxxxx'; $_SESSION['loggedin'] = time(); // redirect logged in user back to this page header("Location: {$_SERVER['PHP_SELF']}"); exit(); } else { // Not okay. print '<p>The submitted username and password do not match those on file!<br />Go back and try again.</p>'; } } else { // Forgot a field. print '<p>Please make sure you enter both a username and a password!<br />Go back and try again.</p>'; } } else { // Basic HTML formatting stuff. print '<h2>Admin Login Form</h2> <p>Please enter your User Name and Password.</p>'; // Display the form. print '<form action="MountainFCgamereports2010_WORKING.php" method="post"><p> Username: <input type="text" name="username" size="20" /><br /> Password: <input type="password" name="password" size="20" /><br /> <input type="submit" name="submit" value="Log In" /></p> </form>'; } // end else } ?> </div> <!--close content --> <!-- InstanceEndEditable --> <div id="footer"><a href="index.htm">Home</a> | <a href="mailto:webmaster@mountainwfc.ca">Webmaster</a> | Copyright © 2008-2010. All rights reserved.<br /> </div><!--close footer --> </div><!--close container --> </body> <!-- InstanceEnd --></html> <?php // Turn off output buffering ob_end_flush(); ?>
  11. User entries into my form fields will not be accepted if the entry is "0" (zero). Text is fine and numbers are fine but zero is not accepted. My html form is using "text" ie: <td colspan="3"><input type="text" name="mountainfcscore" size="5" value="<? echo $mountainfcscore; ?>" /> <? echo $err_mountainfcscore; ?></td> and for my phpMyAdmin table I've tried field types "int", "char" and "varchar" yet it will not write "0" to the table. I can manually enter "0" but not thru the form. Does anyone know what this could be? Thanks Ed
  12. It works!!! The concatenating of the print statement was the final piece of the puzzle. print '<form action="gamereports_APPROVAL.php?game_id= ' . $game_id . ' " method="post">'; Thanks soooooo much for all your help! I can now more forward with this slick game report approval method. Cheers - have a great week! Ed
  13. Thanks! Below I show the portion of code in which I have added those two lines. Unfortunately I didn't seem to have any beneficial effect. What am I doing wrong ? Thanks ! // Define an UPDATE query. $query = "UPDATE MountainFCgamereports2010 SET approved='Yes' WHERE game_id={$game_id}"; $radioset = $_POST['radioset']; if ($radioset == "NO") { print "nothing was changed";// for debugging } elseif ($radioset == "YES") { print "radio was set to YES";// for debugging $result=mysql_query($query); } print '<form action="gamereports_APPROVAL.php?game_id=<?php echo $game_id; ?>" method="post">'; print '<input type="radio" name="radioset" value="YES" />Yes<br />'; print '<input type="radio" name="radioset" value="NO" checked="checked" />No<br />'; print '<input type="submit" name="submit" value="Approve" /></form>';
  14. Thanks so much for looking at this!!! I've included my code - sorry it's so primitive, but it's not a complicated thing I'm trying to do. The code calls up the record by it's game_id thru GET in an email URL and includes username and password. It displays that record by echoing to the screen. Then the $query is replaces by an update query, again using the value for game id. The user clicks yes if they want to approve the game report and on submit causes the page to reload. If they clicked yes the UPDATE query is run and the dbase table is updated. These things are not happening that I would like: 1. The approved field is not being updated at all (except if I use 89 instead of the variable desired) 2. upon submit, the screen refreshes but the original echoed data disappears and only displays the radio and submit buttons. 3. upon clicking yes and submit I would like to have the submit button disappear and a simple note show like "successfully approved" Many thanks. Any further help is much appreciated. Ed HERE'S THE CODE: <?php // Turn on output buffering ob_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Mountain FC - Game Report 2010</title> <div id="content"> <?php // Connect and select. $dbc = @mysql_connect ('localhost', 'username', 'password') or die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>'); $x = @mysql_select_db ('dbase') or die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>'); // Turn off error display ini_set ('display_errors', 0); //Now to retreive the URL variable value: $game_id=$_GET['game_id']; $query = "SELECT * FROM MountainFCgamereports2010 WHERE game_id={$_GET['game_id']}"; $result=mysql_query($query); echo "<br />"; while($row=mysql_fetch_assoc($result)){ ?> <table width="99%" border="0" cellpadding="6" cellspacing="1"> <tr> <td style="background-color:#cc0033"><div align="center"><font color="#FFFFFF"><strong><? echo $row['age_level']; ?> GAME REPORTS</strong></font></div></td> </tr> </table> <? // Output echo "<b>",'Mountain FC ', $row['age_level'] , " vs ", $row['opposition']," ","-"," ",$row['game_month']," ", $row['game_day'],"</b>", "<br />"; echo "<b>",'Location : ',"</b>", $row['location'] , "<br />"; echo "<b>",'Weather : ',"</b>", $row['weather'] , "<br />"; echo "<b>",'Mountain FC - ', $row['mountainfcscore'] ," : ",$row['oppositionscore'] ," - ",$row['opposition'],"</b>", "<br />"; echo "<b>",'Half-time score : ', $row['halftimescore'], "</b>"," (mtn:oppos)","<br />"; echo $row['game_details'],"<br />"; if (!empty($row['scorer1'])) { if (!empty($row['scorer1'])) {echo "Goal #1 scored by: ",$row['scorer1']," ";}else {echo "";} if (!empty($row['assist1_1'])) {echo "Assisted by: ", $row['assist1_1']," ";}else {echo "";} if (!empty($row['assist1_2'])) {echo "and assisted by: ", $row['assist1_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer2'])) { if (!empty($row['scorer2'])) {echo "Goal #2 scored by: ",$row['scorer2']," ";}else {echo "";} if (!empty($row['assist2_1'])) {echo "Assisted by: ", $row['assist2_1']," ";}else {echo "";} if (!empty($row['assist2_2'])) {echo "and assisted by: ", $row['assist2_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer3'])) { if (!empty($row['scorer3'])) {echo "Goal #3 scored by: ",$row['scorer3']," ";}else {echo "";} if (!empty($row['assist3_1'])) {echo "Assisted by: ", $row['assist3_1']," ";}else {echo "";} if (!empty($row['assist3_2'])) {echo "and assisted by: ", $row['assist3_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer4'])) { if (!empty($row['scorer4'])) {echo "Goal #4 scored by: ",$row['scorer4']," ";}else {echo "";} if (!empty($row['assist4_1'])) {echo "Assisted by: ", $row['assist4_1']," ";}else {echo "";} if (!empty($row['assist4_2'])) {echo "and assisted by: ", $row['assist4_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer5'])) { if (!empty($row['scorer5'])) {echo "Goal #5 scored by: ",$row['scorer5']," ";}else {echo "";} if (!empty($row['assist5_1'])) {echo "Assisted by: ", $row['assist5_1']," ";}else {echo "";} if (!empty($row['assist5_2'])) {echo "and assisted by: ", $row['assist5_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer6'])) { if (!empty($row['scorer6'])) {echo "Goal #6 scored by: ",$row['scorer6']," ";}else {echo "";} if (!empty($row['assist6_1'])) {echo "Assisted by: ", $row['assist6_1']," ";}else {echo "";} if (!empty($row['assist6_2'])) {echo "and assisted by: ", $row['assist6_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer7'])) { if (!empty($row['scorer7'])) {echo "Goal #7 scored by: ",$row['scorer7']," ";}else {echo "";} if (!empty($row['assist7_1'])) {echo "Assisted by: ", $row['assist7_1']," ";}else {echo "";} if (!empty($row['assist7_2'])) {echo "and assisted by: ", $row['assist7_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer8'])) { if (!empty($row['scorer8'])) {echo "Goal #8 scored by: ",$row['scorer8']," ";}else {echo "";} if (!empty($row['assist8_1'])) {echo "Assisted by: ", $row['assist8_1']," ";}else {echo "";} if (!empty($row['assist8_2'])) {echo "and assisted by: ", $row['assist8_2']," ";}else {echo "";} echo "<br />"; } if (!empty($row['scorer9'])) { if (!empty($row['scorer9'])) {echo "Goal #9 scored by: ",$row['scorer9']," ";}else {echo "";} if (!empty($row['assist9_1'])) {echo "Assisted by: ", $row['assist9_1']," ";}else {echo "";} if (!empty($row['assist9_2'])) {echo "and assisted by: ", $row['assist9_2']," ";}else {echo "";} echo "<br />"; } echo "<br />","Game id:",$row['game_id'],", Submitted by: ",$row['submittor'], " on ", $row['date_entered'],"<br />"; } //Reset query to nothing $query = ""; // Define an UPDATE query. $query = "UPDATE MountainFCgamereports2010 SET approved='Yes' WHERE game_id={$game_id}"; if ($radioset == "NO") { print "nothing was changed";// for debugging } elseif ($radioset == "YES") { print "radio was set to YES";// for debugging $result=mysql_query($query); } print '<form action="gamereports_APPROVAL.php" method="post">'; print '<input type="radio" name="radioset" value="YES" />Yes<br />'; print '<input type="radio" name="radioset" value="NO" checked="checked" />No<br />'; print '<input type="submit" name="submit" value="Approve" /></form>'; ?> </div> </html> <?php // Turn off output buffering ob_end_flush(); ?>
  15. with using the 89, my table record 'approved' gets populated with "Yes" and the script continuous to run as desired. With using a variable as shown, the $query has game_id= <blank> and stops working. I came across some google references that a $query can't decipher the contents of a variable but didn't understand the solutions. So need some help please. The variables do exist and have a value (not certain that it's defined as numeric) because I use them early in the code to retreive the whole record. Up there I set $game_id = $_GET['game_id']; to capture the record from a URL. Thanks Ed
  16. Please help, I've spent more hours than I'd like to admit on this one..... I need to substitute the 89 with a variable like $game_id in the following line; $query = "UPDATE MountainFCgamereports2010 SET approved='Yes' WHERE game_id=89"; I've tried MANY combinations and syntaxes, but nothing will work.... ugh. $query = "UPDATE MountainFCgamereports2010 SET approved='Yes' WHERE game_id={$game_id}"; $query = "UPDATE MountainFCgamereports2010 SET approved='Yes' WHERE game_id={$_GET['game_id']}"; Thanks for any help! Ed
  17. Spent many more hours trying to apply this ... ugh. But I DO appreciate your response. Following is a bit more detail on my situ if you are willing to help further. Magic quotes ARE enabled. Stripslashes are applied to the form fields. Form works as it should except whenever a double quote is entered into a form field. In this instance, when submit is hit, and the form isn't posted (because of missing text in another field for instance) then the first field data disappears and has to be re-typed (that is IF the user notices it missing!). The two text fields work and the only difference I can think of is that the dbase field type is text instead of varchar()-but I don't want to change all my fields to 'text' nor do I feel I need to. How does one APPLY mysql_real_escape_string in my case? Here's part of my code... if ( isset ($_POST['submit'])) { $first_name = $_POST['first_name']; .... // Define the query. $query = "INSERT INTO coachingapplication_Feb10 (registrant_id, first_name, last_name, home_phone, cell_phone, email, agegroup, level, gender, Cert_CCC, Cert_CCY, Cert_CCS, Cert_BPrep, Cert_BProv, Cert_BNat, Cert_ALic, cmfscyear1, cmfscdiv1, cmfscteam1, cmfscyear2, cmfscdiv2, cmfscteam2, cmfscyear3, cmfscdiv3, cmfscteam3, cmfscyear4, cmfscdiv4, cmfscteam4, other_year1, other_club1, other_div1, other_team1, other_year2, other_club2, other_div2, other_team2, other_year3, other_club3, other_div3, other_team3, other_year4, other_club4, other_div4, other_team4, other_exp, refname1, refaddress1, refphone1, refname2, refaddress2, refphone2, refname3, refaddress3, refphone3, other_info, declaration, date_entered) VALUES (0, '$first_name', '$last_name',...........
  18. Single quotes, when entered into a text field, create an sql error upon Submit. It seems to create the query OK but says there's an SQL syntax error and stalls out on that field. Also any time a double-quote is in a text field, all characters to the right of it GET DELETED upon Submit and have to be re-entered before trying to Submit form again. The two larger textarea fields in the form seem to handle the single and double quotes perfectly. Stripslashes functions correctly and no deleting of data. Yet my code doesn't treat these two areas any differently that the text fields(!?) I have used stripslashes on all posted variables http://www.cmfsc.ca/coachingapplication_Feb10email.php Thanks for any help! Ed
  19. Hi I just wanted to follow up on this issue. First of all thank you so much, it set me on the right path to come up with a working solution. I ended up going with check boxes instead of a select element. I've included my code below hoping that it may be helpful to others. [code]<input type="checkbox" name="formfield[]" value="first_name" checked />first_name<br />[/code] [code]if (isset ($_POST['formfield'])) { if (is_array ($_POST['formfield'])) { $query = "SELECT "; foreach ($_POST['formfield'] as $field) { $query .= "$field, "; } // end foreach } else { print 'formfield is not an array!'; } // end else $stringlength = strlen($query);  // determine number of characters in query $stringlengthtrimmed = ($stringlength - 2); // remove last space and comma from query string $query = substr($query,0,$stringlengthtrimmed)." FROM momentum_apex"; }[/code] Cheers!
  20. Hi guys, The problem I'm having below is related to html output from a drop-down menu with the multiple option. I tried posting into the php/mysql section, got 16 reads but no one offered any help - maybe it's more html?? Anyway, here's what's got me stumped.... I'm having difficulty getting my retrieved database data to display the way I need. I would like to be able to choose the fields to filter out  and I'm using a drop-down menu to do so. It works fine except that instead of displaying all of the chosen fields, it only displays the field coresponding to the LAST item in the drop-down list (rather than ALL the selected ones). I should be able to use Ctrl-click to select the fields I want to display. Here's the relevant code. I hope it's enough. Any help would be greatly appreciated! $querycolumns = $_POST['showcolumns']; $query  = "select {$querycolumns} from momentum_apex"; // Select a sorting criteria. $HTML=<<<HTML <form action="{$_SERVER['PHP_SELF']}" method="post">   <select name="showcolumns" size="3" multiple="multiple">     <option value="role">role</option>     <option value="first_name">first_name</option>     <option value="last_name">last_name</option>   </select>   <input name="filter" type="submit" value="Filter now!" />   </form> HTML; echo $HTML;
  21. Hi guys, I'm a new user to this forum and pretty new to php/sql. Here's what's got me stumped.... I'm having difficulty getting my retrieved database data to display the way I need. I would like to be able to choose the fields to filter out  and I'm using a drop-down menu to do so. It works fine except that instead of displaying all of the chosen fields, it only displays the field coresponding to the LAST item in the drop-down list (rather than ALL the selected ones). I should be able to use Ctrl-click to select the fields I want to display. Here's the relevant code. I hope it's enough. Any help would be greatly appreciated! $querycolumns = $_POST['showcolumns']; $query  = "select {$querycolumns} from momentum_apex"; // Select a sorting criteria. $HTML=<<<HTML <form action="{$_SERVER['PHP_SELF']}" method="post"> <select name="showcolumns" size="3" multiple="multiple">     <option value="role">role</option>     <option value="first_name">first_name</option>     <option value="last_name">last_name</option> </select> <input name="filter" type="submit" value="Filter now!" /> </form><br /> HTML; echo $HTML;
×
×
  • 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.