View Full Version : Getting me started with a form

12-08-2010, 08:17 AM
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)

$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 = null;
$conn = null;

2. A html-form, which need to be converted to a php-form I guess

<h2>Job invoer</h2>

<form action="job_invoeren.php" method="post">
<td width="150">Uw naam:</td>
<td><input type="text" name="JobEmpId" /><td>
<td width="150">Jobomschrijving:</td>
<td><input type="text" name="JobDescr" /></td>
<td width="150">Procesfunctie: </td>
<td><input type="text" name="JobPrfId" /></td>
<td width="150">Installatie: </td>
<td><input type="text" name="JobEqmId" /></td>
<td width="150">Afdeling: </td>
<td><input type="text" name="JobDepId" /></td>
<td width="150">Kostenplaats: </td>
<td><input type="text" name="JobCcrId" /></td>
<td width="150">Installatiesoort: </td>
<td><input type="text" name="JobEqmtId" /></td>
<td width="150">Storingsoorzaak: </td>
<td><input type="text" name="JobFalId" /></td>
<td width="150">Servicecontr.: </td>
<td><input type="text" name="JobSvcId" /></td>
<td width="150">Jobsoort:</td>
<td><input type="text" name="JobWotId" /></td>
<td width="150">Vestiging: </td>
<td><input type="text" name="JobSitId" /></td>
<p><input type="submit" value="Invoeren"></p>


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

12-08-2010, 11:39 AM
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

Use the
$_GET['name'] or
where name represents the name of the field. eg
<input type="text" name="JobDescr" />
$_POST['JobDescr'] will be the var contains the submitted answer

12-08-2010, 12:29 PM
Thank you for you reply !

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