How to combine and pass data in one page?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I didn't know what to use as a title for this.  Here is the scenario:

I have a op.reqedit.php page.  This page a form where you input data.
In this page I have split a MySQL field.  It is called
MachineTypeOfWork and is split into Replace, Adjusted, REbuild,
Inspected and Repair. These all become check boxes for the user.  The
form submits to op.reqadd.php.  In this page I first have a hidden box
where I combine all of the above into Type (this works fine, I have
unhidden the box to see it).  Then I have

$MachineTypeofWork = $_GET['Type'];
$sql_query = mysql_query("UPDATE results SET (a bunch of fields)
MachineTypeOfWork='$MachineTypeofWork' WHERE WorkOrder = '$wo'") or die

My problem is that it updates all of the fields it should except the
MachineTypeOfWork field in MySQL.  It actually overwrites what is
already there with nothing.

What I do not know (I am new) is can I combine the field and pass it to
the database in the same page or do I need another page in the
background for this?

ANy help is appreciated.


Re: How to combine and pass data in one page? wrote (in part):
Quoted text here. Click to load it

What is the method that is used on your form? The above will be valid
if the method is "get", if it is "post" use $_POST['Type'] instead.

Quoted text here. Click to load it

If you set a variable to the query string and then echo the string,
what is printed?

When your script start, dump the $_GET and $_POST superarrays and check
what your script is receiving.

echo '<pre>';print_r($_POST);echo '</pre>';
echo '<pre>';print_r($_GET);echo '</pre>';

Let us know the results.


Re: How to combine and pass data in one page?

I am using Get (and it works for all of the other fields.  Here is what
I have in the beginning of my reqadd page to pull everything together.
It is unhidden now to make sure it works.

$Replace = $_GET['Replace'];
$Adjusted = $_GET['Adjusted'];
$Rebuild = $_GET['Rebuild'];
$Inspected = $_GET['Inspected'];
$Repair = $_GET['Repair'];
<INPUT NAME="Type" Value="<?if ($Replace !='Replace')print "0";else
echo $Replace;?>.<?if ($Adjusted != 'Adjusted')print "0";else echo
$Adjusted;?>.<?if ($Rebuild != 'Rebuild')print "0";else echo
$Rebuild;?>.<?if ($Inspected != 'Inspected')print "0";else echo
$Inspected;?>.<?if ($Repair !='Repair')print "0";else echo

$MachineTypeOfWork = $_GET['Type'];

This prints out correctly, but now when I continue with anything. Even
Echo $MachineTypeOfWork it prints out nothing.  When I run the script
you gave me I get

    [wo] => 2
    [MachineAssignedTo] => adfweg
    [MachineDateAssigned] => 07/20/05
    [MachineDateDue] => werf
    [MachineDateCompleted] => aewrv
    [MachineFollowUp] =>
    [Replace] => Replace
    [Adjusted] => Adjusted
    [Rebuild] => Rebuild
    [Inspected] => Inspected
    [Repair] => Repair
    [MachineWorkDone] =>
    [MachineMaterialsUsed] =>

This is correct, it's all coming across.  With the code above it also
prints out correctly (Replace.Adjusted.Rebuild.Inspected.Repair), It's
just that from this point on I seem to not be able to convert it to the
MYSQL field that I need it to send to.

Site Timeline