How to combine and pass data in one page?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tina.boroff@gmail.com

    #1

    How to combine and pass data in one page?

    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
    MachineTypeOfWo rk 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

    $MachineTypeofW ork = $_GET['Type'];
    $sql_query = mysql_query("UP DATE results SET (a bunch of fields)
    MachineTypeOfWo rk='$MachineTyp eofWork' WHERE WorkOrder = '$wo'") or die
    (mysql_error()) ;

    My problem is that it updates all of the fields it should except the
    MachineTypeOfWo rk 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.

    Tina

  • Ken Robinson

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



    tina.boroff@gma il.com wrote (in part):[color=blue]
    > I didn't know what to use as a title for this. Here is the scenario:
    >
    > $MachineTypeofW ork = $_GET['Type'];[/color]

    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.
    [color=blue]
    > $sql_query = mysql_query("UP DATE results SET (a bunch of fields)
    > MachineTypeOfWo rk='$MachineTyp eofWork' WHERE WorkOrder = '$wo'") or die
    > (mysql_error()) ;[/color]

    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.

    Ken

    Comment

    • tina.boroff@gmail.com

      #3
      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'];
      ?>
      <html>
      <INPUT NAME="Type" Value="<?if ($Replace !='Replace')pri nt "0";else
      echo $Replace;?>.<?i f ($Adjusted != 'Adjusted')prin t "0";else echo
      $Adjusted;?>.<? if ($Rebuild != 'Rebuild')print "0";else echo
      $Rebuild;?>.<?i f ($Inspected != 'Inspected')pri nt "0";else echo
      $Inspected;?>.< ?if ($Repair !='Repair')prin t "0";else echo
      $Repair;?>"></html>

      <?
      $MachineTypeOfW ork = $_GET['Type'];

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

      [wo] => 2
      [MachineAssigned To] => adfweg
      [MachineDateAssi gned] => 07/20/05
      [MachineDateDue] => werf
      [MachineDateComp leted] => aewrv
      [MachineFollowUp] =>
      [Replace] => Replace
      [Adjusted] => Adjusted
      [Rebuild] => Rebuild
      [Inspected] => Inspected
      [Repair] => Repair
      [MachineWorkDone] =>
      [MachineMaterial sUsed] =>

      This is correct, it's all coming across. With the code above it also
      prints out correctly (Replace.Adjust ed.Rebuild.Insp ected.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.

      Comment

      Working...