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.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting me started with a form

    Hello all,

    I'm feeling REALLY stupid, I'm sorry !!

    Situation :
    We have a maintenance-program, running on a SQL-server. The Technical Director would like to have a very simple webform for technicians to enter a job they have done during the day.

    -- Yes, just one simple form with only 11 fields --

    Already done :
    I searched the web and tried a lot of things for 2 months now, bought a "PHP for dummies" - book.

    -- Call me stupid or whatever, but I cann't get it to work --

    What I have so far :
    1. Connection to the database ! (in a testfile)

    Code:
    <?php
    $myServer = "SERVER";
    $myUser = "USER";
    $myPass = "PASSWORD";
    $myDB = "Ultimo"; 
    
    //create an instance of the ADO connection object
    $conn = new COM ("ADODB.Connection")
    or die("Cannot start ADO");
    
    //define connection string, specify database driver
    $connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB; 
    $conn->open($connStr); //Open the connection to the database
    
    //declare the SQL statement that will query the database
    $query = "SELECT * FROM dba.Job";
    
    //execute the SQL statement and return records
    $rs = $conn->execute($query);
    
    $num_columns = $rs->Fields->Count();
    echo "Totaal aantal open jobs: " . $num_columns . "<br>"; 
    
    for ($i=0; $i < $num_columns; $i++) {
    $fld[$i] = $rs->Fields($i);
    }
    
    echo "<table>"; 
    while (!$rs->EOF) //carry on looping through while there are records
    {
    echo "<tr>";
    for ($i=0; $i < $num_columns; $i++) {
    echo "<td>" . $fld[$i]->value . "</td>";
    }
    echo "</tr>";
    $rs->MoveNext(); //move on to the next record
    }
    
    
    echo "</table>";
    
    //close the connection and recordset objects freeing up resources 
    $rs->Close();
    $conn->Close();
    
    $rs = null;
    $conn = null;
    ?>
    2. A html-form, which need to be converted to a php-form I guess

    Code:
    <html>
    <body>
    <h2>Job invoer</h2>
    
    <form action="job_invoeren.php" method="post">
    <table>
    <tr>
    <td width="150">Uw naam:</td>
    <td><input type="text" name="JobEmpId" /><td>
    </tr>
    <tr>
    <td width="150">Jobomschrijving:</td>
    <td><input type="text" name="JobDescr" /></td>
    </tr>
    <tr>
    <td>&nbsp</td><td></td>
    </tr>
    <tr>
    <td width="150">Procesfunctie: </td>
    <td><input type="text" name="JobPrfId" /></td>
    </tr>
    <tr>
    <td width="150">Installatie: </td>
    <td><input type="text" name="JobEqmId" /></td>
    </tr>
    <tr>
    <td width="150">Afdeling: </td>
    <td><input type="text" name="JobDepId" /></td>
    </tr>
    <tr>
    <td width="150">Kostenplaats: </td>
    <td><input type="text" name="JobCcrId" /></td>
    </tr>
    <tr>
    <td>&nbsp</td><td></td>
    </tr>
    <tr>
    <td width="150">Installatiesoort: </td>
    <td><input type="text" name="JobEqmtId" /></td>
    </tr>
    <tr>
    <td width="150">Storingsoorzaak: </td>
    <td><input type="text" name="JobFalId" /></td>
    </tr>
    <tr>
    <td width="150">Servicecontr.: </td>
    <td><input type="text" name="JobSvcId" /></td>
    </tr>
    <tr>
    <td width="150">Jobsoort:</td> 
    <td><input type="text" name="JobWotId" /></td>
    </tr>
    <tr>
    <td width="150">Vestiging: </td>
    <td><input type="text" name="JobSitId" /></td>
    </table>
    <p><input type="submit" value="Invoeren"></p>
    </form>
    
    </body>
    </html>
    The stupid part
    Could somebody please get me started with a following thing ?
    Almost everything (not "JobDescr") hase to be selected from the database. So I would like to have a dropdownbox for all the fields (not JobDescr)

    Example :
    JobEmpId : Field EmpId from table dba.Employee but I need to see field EmpDescr (where the actual name is stored)

    Could somebody please give me the code to get 1 field working, so I can make the rest working too ?

    Please keep in mind that an SQL (NOT MySQL) is used and I need to see EmpDescr and store EmpId in JobEmpId

    Greetings and hope from
    Jochen, Belgium

  • #2
    Regular Coder adarshakb's Avatar
    Join Date
    Jun 2009
    Location
    Silicon valley of india
    Posts
    247
    Thanks
    11
    Thanked 1 Time in 1 Post
    Consider putting it in projects section and get someone done for money if you donot know how to do.

    If you dono how to get the results submitted by the form in php use this tutorial
    http://www.nyphp.org/PHundamentals/5...aying-Database

    Use the
    $_GET['name']
    or
    $_POST['name']
    where name represents the name of the field. eg
    for
    <input type="text" name="JobDescr" />
    $_POST['JobDescr'] will be the var contains the submitted answer
    Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.

    Albert Einstein
    -----------------------------------------------------
    My Blog songs

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for you reply !

    I would like to make it myself, so I can learn...


  •  

    Posting Permissions

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