473,715 Members | 6,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Complex Form Question

SHOverine
18 New Member
I have a 3-part form that I am having trouble with. First part is to select the user group and the week and year that I want to submit results for, this calls the elements that I want to update.

The second part is to enter the results and submit them to a MySQL table called results the final part echoes the results.

The issue is that my form writes the elements that I called up to the this table before I enter the results and click the submit button. I attached a simplified version of my code below:


Thanks for your help
Cheers,
Seth
_______________ _______________ _______________ _______________ _
FORM 1:
<?php

include("php/common.php");
include("php/db.php");
session_start() ;
// RESULTS1.PHP
// DISPLAY FORM 1 - GET USER GROUP AND GAME INFORMATION
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="content-type"content="t ext/html; charset=ISO-8859-1">
<html>
<head><title>Th e Weekly 13: Results Manager</title></head>
<body style="backgrou nd-image: url

(http://theweekly13.com/images/core/pabstheaderbg.j pg);">
<h1 style="text-align: center; font-family: Arial;"><font color="#000099" >
The Weekly 13: Game Results Manager</font></h1>

<form style="font-family: Arial;" method="POST" name="results1. php"
action="results 2.php">

<table style="text-align: left; width: 35%;" border="0" cellpadding="0"

cellspacing="0" >
<tbody>
<tr>
<td style="width: 83px;" colspan="1" rowspan="3">
<img style="width: 80px; height: 83px;"alt=""

src="http://theweekly13.com/images/core/pabstheader.jpg ">
</td>
<td style="text-align: right; width: 25%; font-weight: bold;">Season:
</td>
<td align="undefine d" valign="undefin ed"><input size="5" name="Year"

value="2006">
</td>
</tr>
<tr>
<td style="text-align: right; font-weight:

bold;"valign="u ndefined">Leagu e:
</td>
<td>

<?php // GET LEAGUE
include_once 'php/db.php';
dbConnect("thew eekl_test");
$query = mysql_query("SE LECT League, LeagueNumber FROM Leagues");
echo "<form action=somethin g.php method=POST> <select name=League>";
while ($r = mysql_fetch_arr ay($query))
{ $League = $r["League"]; $LeagueNumber = $r["LeagueNumb er"];
echo "<option value='$LeagueN umber'>$League</option>";
} echo "</select>"; ?>
</td>
</tr>
<tr>
<td style="text-align: right; font-weight: bold;">Week:
</td>
<td>

<?php // GET WEEK
include_once 'php/db.php';
dbConnect("thew eekl_test");
$query = mysql_query("SE LECT WeekName, WeekID FROM Weeks");
echo "<form action=somethin g.php method=POST>
<select name=Week>";
while ($r = mysql_fetch_arr ay($query))
{ $Week = $r["WeekName"]; $WeekID = $r["WeekID"];
echo "<option value='$WeekID' >$Week</option>";
} echo "</select>";
?>
</td>
</tr>
<tr>
<td colspan="3" rowspan="1" align="undefine d" valign="undefin ed">
<hr noshade="noshad e">
<div style="text-align: right;"><input value="Reset Form"

type="reset">
<input name="submitok" value=" OK " type="submit">
</div>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>


_______________ _______________ _______________ _______________ __
FORM 2:

<?php
include("php/common.php");
include("php/db.php");
if (!isset($_POST['submitok2'])) {
//RESULTS2.PHP
// DISPLAY FORM 2 - GET GAME INFORMATION, POPULATE FORM 2
?>

<title>Weekly 13: Game Results Manager</title>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<body style="backgrou nd-image: url

(http://theweekly13.com/images/core/pabstheaderbg.j pg);">
<h1 style="text-align: center; font-family: Arial;"><font
color="#000099" >The Weekly 13: Game Results Manager</font></h1>
<br>

<form method="post" action="results 3.php"
name="results2. php">
<input type="hidden" name="Year" value="<?=$Year ?>">
<input type="hidden" name="Week" value="<?=$Week ?>">
<input type="hidden" name="League" value="<?=$Leag ue?>">
<table style="text-align: left; width: 35%;" border="0"
cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td style="width: 83px;" colspan="1"
rowspan="3"><im g style="width: 80px; height: 83px;"
alt="" src="http://theweekly13.com/images/core/pabstheader.jpg "></td>
<td style="text-align: right; width: 25%; font-weight: bold;">Season:
</td>
<td align="undefine d" valign="undefin ed">
<?php echo $Year; ?>
</td>
</tr>
<tr>
<td style="text-align: right; font-weight: bold;"
valign="undefin ed">League:</td>
<td>
<?php
include_once 'php/db.php';
dbConnect('thew eekl_test');
$sqlA = "SELECT League FROM Leagues WHERE LeagueNumber = $League";
$queryA = mysql_query($sq lA);
$LeagueName = mysql_result($q ueryA, 0);
echo $LeagueName; ?>
</td>
</tr>
<tr>
<td style="text-align: right; font-weight: bold;">Week:
</td>
<td>
<?php echo $Week; ?>
</td>
</tr>
</tbody>
</table>
<hr style="width: 100%; height: 2px;"><font
color="#000099" >
<table style="text-align: left; width: 100%;" border="0"
cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td
style="text-align: center; width: 10%; font-weight: bold; font-family:

Arial;">GameID</td>
<td
style="text-align: center; width: 25%; font-weight: bold; font-family:

Arial;">Away
Team (line)</td>
<td
style="text-align: center; width: 7%; font-weight: bold; font-family:

Arial;">Away
Score</td>
<td
style="text-align: center; width: 25%; font-weight: bold; font-family:

Arial;">Home
Team (line)</td>
<td
style="text-align: center; width: 8%; font-weight: bold; font-family:

Arial;">Home
<br>
Score</td>
</tr>
<tr>
<td style="text-align: center;" valign="undefin ed">
<?php
include_once 'php/db.php';
dbConnect('thew eekl_test');
$sql1 = "SELECT GameID FROM Games WHERE League = $League AND WeekID = $Week

and Game = '1'";
$query1 = mysql_query($sq l1);
$Game1 = mysql_result($q uery1, 0);
echo $Game1;
?></td>
<td style="text-align: center;" valign="undefin ed">
<?php
dbConnect('thew eekl_test');
include_once 'php/db.php';
$sql1A = "SELECT AwayTeam FROM Games WHERE League = $League AND WeekID =

$Week and Game = '1'";
$query1A = mysql_query($sq l1A);
$AwayTeam1 = mysql_result($q uery1A, 0);
echo $AwayTeam1;
?>&nbsp;
<?php
include_once 'php/db.php';
dbConnect('thew eekl_test');
$sql1AA = "SELECT AwayLine FROM Games WHERE League = $League AND WeekID =

$Week and Game = '1'";
$query1AA = mysql_query($sq l1AA);
$AwayLine1 = mysql_result($q uery1AA, 0);
echo $AwayLine1;
?>
</td>
<td style="text-align: center;" valign="undefin ed"><input
size="4" name="AwayScore 1"></td>
<td style="text-align: center;" valign="undefin ed">
<?php
include_once 'php/db.php';
dbConnect('thew eekl_test');
$sql1B = "SELECT HomeTeam FROM Games WHERE League = $League AND WeekID =

$Week and Game = '1'";
$query1B = mysql_query($sq l1B);
$HomeTeam1 = mysql_result($q uery1B, 0);
echo $HomeTeam1;
?>&nbsp;
<?php
include_once 'php/db.php';
dbConnect('thew eekl_test');
$sql1BB = "SELECT HomeLine FROM Games WHERE League = $League AND WeekID =

$Week and Game = '1'";
$query1BB = mysql_query($sq l1BB);
$HomeLine1 = mysql_result($q uery1BB, 0);
echo $HomeLine1;
?>
</td>
<td style="text-align: center;"><input size="4"
name="HomeScore 1"></td>
</tr>
<tr>
<td colspan="6" rowspan="1" align="undefine d" valign="undefin ed">
<hr noshade="noshad e">
<div style="text-align: right;"><input value="Reset Form"

type="reset">
<input name="submitok2 " value=" OK " type="submit">
</div>
</td>
</tr>
</tbody>
</table>
</font>
</form>
<?php } ?>
</body>
</html>

<?php

include_once 'php/db.php';
dbConnect('thew eekl_test');
//PROCESS GAME RESULTS

$sql1 = "INSERT INTO Results (ResultID, GameID, AwayTeam, HomeTeam,

AwayScore, HomeScore, Cover) VALUES ('', '$Game1', '$AwayTeam1',

'$HomeTeam1', '$AwayScore1', '$HomeScore1', '')";
mysql_query($sq l1) or die(mysql_error ());
?>
Sep 26 '06 #1
4 2384
ronverdonk
4,258 Recognized Expert Specialist
My guess is that the 3rd part of your form, i.e.
[PHP]<?php

include_once 'php/db.php';
dbConnect('thew eekl_test');
//PROCESS GAME RESULTS

$sql1 = "INSERT INTO Results (ResultID, GameID, AwayTeam, HomeTeam,

AwayScore, HomeScore, Cover) VALUES ('', '$Game1', '$AwayTeam1',

'$HomeTeam1', '$AwayScore1', '$HomeScore1', '')";
mysql_query($sq l1) or die(mysql_error ());
?>
[/PHP]
is not a separate script but is stuck at the end of your second script Result2.php. That means that, whatever you do in your second script will always be followed by an update to the MySql database.

Ronald :cool:
Sep 27 '06 #2
SHOverine
18 New Member
My guess is that the 3rd part of your form, i.e.
[PHP]<?php

include_once 'php/db.php';
dbConnect('thew eekl_test');
//PROCESS GAME RESULTS

$sql1 = "INSERT INTO Results (ResultID, GameID, AwayTeam, HomeTeam,

AwayScore, HomeScore, Cover) VALUES ('', '$Game1', '$AwayTeam1',

'$HomeTeam1', '$AwayScore1', '$HomeScore1', '')";
mysql_query($sq l1) or die(mysql_error ());
?>
[/PHP]
is not a separate script but is stuck at the end of your second script Result2.php. That means that, whatever you do in your second script will always be followed by an update to the MySql database.

Ronald :cool:

This is what I desire - "whatever you do in your second script will always be followed by an update to the MySql database."

But what I do in the first First form gets written in my table - it writes the row before I enter values into the "AwayScore" and "HomeScore" fields. I verified this by checking the table right after I hit the 1st submit ("submitok") . My code writes a row that has the correct ResultID, GameID, AwayTeam, and HomeTeam and writes Zeros for the AwayScore and HomeScore before I click the second submit button.

Cheers,
Seth
Sep 27 '06 #3
ronverdonk
4,258 Recognized Expert Specialist
That's exactly what I said. The data is always written to the database if you have the UPDATE code in your second script.

The MySql UPDATE code DOES NOT WAIT for a submit button to be hit, it just continues processing after the </form> statement in your 2nd script. The code does not have an event listener that catches something (such as submit) and then continues its processing.

What you should do is put the MySql UPDATE statement in a 3rd script (e.g. Results3.php) and let that script be called by the form in your 2nd script. As follows:

Results1.php: hit submit --> action=Results2 .php
Results2.php: hit submit --> action=Results3 .php
Results3.php : perform the MySql UPDATE command

Ronald :cool:
Sep 27 '06 #4
SHOverine
18 New Member
Thanks Ronald! One more thing I had to do is to set the $_SESSION variables so the team names and game ids would carry all the way to form three. Works like a charm :-)

CHeers,
Seth
Sep 27 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3455
by: Paul Bramscher | last post by:
Here's one for pathological SQL programmers. I've got a table of things called elements. They're components, sort of like amino acids, which come together to form complex web pages -- as nodes in trees which form parent-child relationships, sort of like newsgroups. For example, the parent_id field points to another element. Indent_level is there for denormalization purposes, to avoid costly recursive issues in querying. The...
2
3548
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out *what the user wants*. I've had brief formal education about data flow diagramming, but I'm looking for ... more, now that I'm actually running into problems I think stem from the fact that my users can't explain what they need done, compounded by...
8
2960
by: Steve Jorgensen | last post by:
Mailing List management is a good example of a case where my conundrum arises. Say there is a m-m relationship between parties and groups - anyone can be a member of any combintation of groups. Now, let's say the user wants to be able to send mailings to people who have various combinations of membership and non-membership in those groups. Here's a medium-complex example: (Knitting Group or Macrame Group) and Active Contact and Mailing...
4
1167
by: Robert W. | last post by:
I'm thinking of building a complex data model with a number of nested classes but need to know something first. To simplify my question, let me present you this sample data model MainClass Questions (collection) Question (class) Text (property) Answers (collection) Answer (class)
12
1572
by: Russ | last post by:
I tried the following: >>> x = complex(4) >>> y = x >>> y *= 2 >>> print x, y (4+0j) (8+0j) But when I tried the same thing with my own class in place of "complex" above, I found that both x and y were doubled. I'd like to
3
2055
by: Russ | last post by:
I'd like to get output formatting for my own classes that mimics the built-in output formatting. For example, >>> x = 4.54 >>> print "%4.2f" % x 4.54 In other words, if I substitute a class instance for "x" above, I'd like to make the format string apply to an element or elements of the instance. Can I somehow overload the "%" operator for that? Thanks.
6
1722
by: pippapippa | last post by:
I should be most grateful for a little advice. I have used Access 2000 & latterly 2002. Am about to upgrade since it is evident that documentation, tutorials etc are more readily available in later versions. I work on this on my lonesome & do not have access to a mentor or tuition. This is an intermittent activity and quite adjunct to my "normal" investment activities. I have found that most books & documentation are either...
1
9471
by: perroe | last post by:
Hi I have a array of complex numbers that are stored in a simple double array. This is done since the array is part of an wrapper for an external C library, and the imaginary part of the first element, and the last element are known to be 0. I've implemented a -operator that returns a ComplexReference object that basically maps a complex<doubleinto the storage used in the array. What I would like to do is using the ComplexReference...
7
2376
by: schaefer.mp | last post by:
To compute the absolute value of a negative base raised to a fractional exponent such as: z = (-3)^4.5 you can compute the real and imaginary parts and then convert to the polar form to get the correct value: real_part = ( 3^-4.5 ) * cos( -4.5 * pi ) imag_part = ( 3^-4.5 ) * sin( -4.5 * pi )
3
1489
by: BUmed | last post by:
Ok let me start from the start. I have a form that has question in it and the person chooses 0 1 2 -99 for each. The form then needs to add up the numbers for the sub categories in the form. For example question 1-8 deal with communication and can rang from 0 to 16 points. The problem that I'm running into is the -99 which is needed to denote that the question does not ably. So if one of the communication questions is NA then it will make the...
0
8823
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9198
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.