...

View Full Version : Getting me started with a form



jochenAndries
12-08-2010, 09: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)


<?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


<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

adarshakb
12-08-2010, 12:39 PM
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_Storing-Data-Submitted-Form-Displaying-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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum