Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying my Query

    I have a table that has data in it that people have submitted via a form. Now I want to review that same data in the form that it was originally completed in. Is it possible to display this data, in the format by using one of the columns as an identifier..

    Basically, these are work orders and if I key in a work order #, I want the work order to come up in the form, where I can review it, and then update it, after i have added comments and a purchase order #.

    If someone can put me in the direction I need to go, it would be appreciated, I am new to this and totally confused. I think I would use the SELECT but not sure how to get it back into the form.

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Is this a web form? I assume that is the case. In any event, you would select the data from the table and filtering on the work order number you entered in.

    e.g.
    Code:
    SELECT column1, column2, column3 FROM yourtable WHERE workorder = numberyouentered
    Then you would just set the default values of the fields in the form using the data returned from the query.
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much for the quick reply. when you say set the default values on the fields, do you mean, I would put a command in each field that corresponds to the column name?

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Well, can you clarify where the form is? Like is it a webpage or is the form in an application?
    OracleGuy

  • #5
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the form is a webpage... Let me try to explain what I am trying to accomplish.

    When some engines go down, we need the techs to fill out the work order and submit it to the database (I have this working). A supervisor will then review the workorder, make any comments (in a field that wasn't available to original tech) and assign a purchase order to it. (purchase order not available to tech either) The original tech will then be able to review the form and use the purchase order to order parts for this engine....the process will continue until it is closed when the repair is finished, but I am not that far. It will basically repeat the process once I get this second step working.

    Here is what i have for the SELECT query, but not sure if I am even close to getting it to work....

    Code:
    <?php
    include_once "myconnect.php";
    ?>
    <form action="" method="post" enctype="multipart/form-data">
    <center><div>Work Order #:<input type="text" size="10" maxlength="10" name="woorder">
    <?php $query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
    Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
    Safety, Image1, Image2, Image3, Image4 FROM work WHERE Work=$woorder")or die(mysql_error())
    ;?>
    <div><input type="submit" name="Submit" value="Request Work Order"></div>
    </form>

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Alright, you are headed in the right direction.

    Code:
    <form action="nextpage.php" method="post">
    <center><div>Work Order #:<input type="text" size="10" maxlength="10" name="woorder">
    <div><input type="submit" name="Submit" value="Request Work Order"></div>
    nextpage.php
    Code:
    <?php
    include_once "myconnect.php";
    $query=mysql_query("SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
    Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
    Safety, Image1, Image2, Image3, Image4 FROM work WHERE Work=$woorder")or die(mysql_error())
    ;?>
    
    <form action="" method="post">
    <input type="text" value="<? echo mysql_result($query, 0, 'Work') ?>" size="10" id="Work">
    </form>
    This is sort of what I mean by set the default values. When the page loads the value for work will be already loaded into the textbox. This is a very basic example but should hopefully get you going in the right direction.

    And you have to make sure the $woorder variable gets set on the next page and stuff.
    OracleGuy

  • #7
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank You very much.....this will get me going, where I should be able to put together something. Your willingness to share your talents is greatly appreciated.

    Ken

  • #8
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quick Question, just so I am understanding what is happening.

    value="<? echo mysql_result($query, 0, 'Work')
    What does the 0 do, between the $query and Work I am thinking that the query is the query we ran, and the work is the name of the column in the DB, but not sure about the 0.

    thanks

  • #9
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The 0 says "get the first row of the query (row zero)". In the case you had several rows with a work order that matched, you'd need to specify which one you wanted.

    mysql_result definition

  • #10
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I thought I had this working the way it was suppose to, but then I changed the table name, and one of the fields, as it was getting confusing as the names were all the same...... and now for some reason, it won't work. I am wondering if you can tell what isn't right.

    This is the error I am getting. Before I changed the name, the old name wasn't in my DB anywhere, so I am not sure what is causing this.
    Unknown column '$Contact' in 'where clause'
    Code:
    <?php
    include_once "myconnect.php";
    $query=mysql_query('SELECT Work, Sched, Name, Site, Serial, Hours, Starts, Issue, Severity,
    Resolution, Assistance, PartsA, PartsB, PartsC, PartsD, PartsE, PartsF, PartsG,
    Safety, Image1, Image2, Image3, Image4 FROM workorder WHERE Work=$Contact')or die(mysql_error());?>
    
    <form action="" method="post">
    <head>
    <!--<link href="ge.css" rel="stylesheet" type="text/css"> -->
    <title>GE Work Order</title>
    </head>
    <BODY BGCOLOR="gainsboro">
    <?php
    /* womanager.php */
    if (!isset($_POST['Submit'])){
    ?>
    Purchase Order #:<input type="text" size="12" maxlength="120" name="Purchase">
    <center><div>Work Order #:<input type="text" value="<?php echo mysql_result($query, 0, 'Work') ?>" size="10" id="Work">
    Date:<input type="text" value="<?php echo mysql_result($query, 0, 'Sched') ?>" size="10" id="Sched">

  • #11
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    $Contact is a PHP variable, or at least that's how you're trying to use it. Where are you setting its value? Is your column "Work" an integer? If not, you'll need to enclose $Contact in quotes.

  • #12
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the tip on this. I am feeling dumb, but, I can't figure out how to set the value of $contact. I know that $contact=work but I am not sure how to set it up. Work is a varchar in the table, but contact is not in the table.

    Ken

  • #13
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have got it to the point where it isn't generating errors, but now it is putting the code in where the fields normally go, and i am thinking this is because i don't have it thinking that it is in php mode. If I take the " out after value and after the ?> then it doesn't put it in the text field, and it is now in php mode, but, then the closing php tag is in the text field.

    Here is what I have for the line of code and this is appearing in the textbox.
    Code:
    <center><div>Work Order #:<input type="text" value="<? echo mysql_result($query, 0, 'Work') ?>" size="10" id="Work">
    When you say that I need to "set the variable" is this what you mean?
    $Contact = $_POST['Work'];

  • #14
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    So it is just showing the PHP code?

    Try changing it from "<? echo mysql_result($query, 0, 'Work') ?>" to "<?php echo mysql_result($query, 0, 'Work') ?>"

    Your server's PHP configuration might not be setup to accept the former method of encapsulating PHP code.
    OracleGuy

  • #15
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is actually working exactly like it is suppose to, except for the fields tht are textboxes. They only display one row of text, so some text gets cut off. Is it possible to have 4 rows, which matches what they had on th origianal form.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •