Jump to content

Writing to foreign keys


taz321

Recommended Posts

i have a minor problem here which i will try to explain the best i can.

 

This is a table called form with their attributes.

 

ssuetitle

datesubmitted

systemaffected

prioritylevel

issuedetails

supportcomments

clientFname

clientSurname

teamname

empName

clientID

employeeID

 

I have used a hidden field to pass data into the clientID but am having trouble doing it for the employee ID.

 

Bascially an person would log into a system after which they would be required to fill in a form. (this is a helpdesk system and the person would log a call by filling in the form)

 

There are fields in the form which require the person's details which is name and teamname and clientID, these are automatically filled in when they login to the system.

 

The clientID of the person is put into the hidden field so that it adds to the form table.

 

The problem is here.

 

When the person completes the form, they can assign this task to an employee by selecting the name of the employee on a drop down box.

But the ID of that employee is determined by the person filling in the form because they would determine which employee to choose from the drop down box.

But im not sure of the code to do this, i hope this makes sense.

 

This is the login script when the user logs in, and where data is automatically filled in when the user logs in.

 

<?php

  session_start();

  require "connect.php";

  $username = $_GET['username'];

  $password = $_GET['password'];

  $query = "select * from client where username='".$username."' AND password='".$password."'";

 

  $result = mysql_query($query, $connection) or die ("Unable to perform query

$query");

 

  $row=mysql_fetch_array($result);

 

  if($row != null)

  {

      $_SESSION['username'] = $row['username'];

  $_SESSION['firstname'] = $row['firstname'];

  $_SESSION['surname'] = $row['surname'];

  $_SESSION['teamname'] = $row['teamname'];

  $_SESSION['clientID'] = $row['clientID'];

      header("Location: ClientForm.php");

      exit();

  }

  else

  {

      $message = "Invalid UserName or Password, Please Try Again";

      header("Location: ClientLogin.php?message=$message");

      exit();

  }

?>

 

This script adds the form to the database.

 

 

<?php

require "connect.php";

$issuetitle = $_GET['issuetitle'];

$datesubmitted = $_GET['datesubmitted'];

$systemaffected = $_GET['systemaffected'];

$prioritylevel = $_GET['prioritylevel'];

$issuedetails = $_GET['issuedetails'];

$supportcomments = $_GET['supportcomments'];

$clientFname = $_GET['clientname'];

$clientSurname = $_GET['clientSurname'];

$teamname = $_GET['teamname'];

$empName = $_GET['empName'];

$clientID = $_GET['clientID'];

$employeeID = $_GET['employeeID'];

 

$query = "insert into ClientForm values ('','".$issuetitle."','".$datesubmitted."','".$systemaffected."','".$prioritylevel."','".$issuedetails."', '".$supportcomments."', '".$clientFname."', '".$clientSurname."','".$teamname."', '".$empName."', '".$clientID."', '".$employeeID."'  )";

$result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query");

header("Location: ClientForm.php");

exit();

?>

 

Thanks

 

 

 

Link to comment
Share on other sites

From the you explain it is sounds like you are trying to have an employee assign another employee

But you have no field for it.

 

All you have to do is add a column and field called assigned_employeeID

And pull the data from the employeeID.

 

That way they can choose from a drop down and make it so if employeeID(filling out the form) = assigned_employeeID it doesn't show up in the form unless you want them to be able to assign jobs to themselves.

 

Link to comment
Share on other sites

Hi

 

Its not necessarily an employee assigning another employee.

 

Its a client assigning an employee to deal with their problem.

 

This is my form - and within the code you'll see a loop which displays all employees in the employee table and this is shown in a drop down box.

Im still abit confused as to how i would get the employeeID, can you shoe me any example code - Thanks.

 

<?php

session_start();

if (isset($_SESSION['username']) == false){

header("Location:ClientLogin.php");

exit();

}

?>

 

<?php

 

    require "connect.php";

$query =  "select * from employee order by surname";

$result = @mysql_query($query, $connection)

    or die ("Unable to perform query<br>$query");

?>

 

 

 

<?php

 

require "connect.php";

$query1 = "select * from form";

$result1 = mysql_query($query1, $connection)

or die ("MySQL Error: ".mysql_error());

 

?>

 

<head>

<title>Jupiter Development Support</title>

<link href="Images/mystyle.css" rel="stylesheet" type="text/css">

 

<style type="text/css">

<!--

#Layer2 {position:absolute;

width:200px;

height:52px;

z-index:2;

left: 16px;

top: 143px;

}

#Layer1 {position:absolute;

width:200px;

height:80px;

z-index:1;

left: 254px;

top: 84px;

}

.style1 {font-family: "Copperplate Gothic Bold"}

#Layer3 {

position:absolute;

width:200px;

height:115px;

z-index:3;

left: 306px;

top: 255px;

}

#Layer4 {

position:absolute;

width:200px;

height:115px;

z-index:3;

left: 842px;

top: 200px;

}

.style3 {font-family: "Copperplate Gothic Bold"; font-size: x-large; }

#Layer5 {

position:absolute;

width:400px;

height:36px;

z-index:3;

left: 390px;

top: 207px;

}

.style5 {font-family: "Copperplate Gothic Bold"; font-size: small; }

.style6 {

font-family: "Comic Sans MS";

font-size: xx-small;

}

.style7 { font-family: "Copperplate Gothic Bold";

font-size: medium;

font-weight: bold;

}

#Layer6 {

position:absolute;

width:137px;

height:130px;

z-index:4;

left: 906px;

top: 199px;

}

#Layer7 {

position:absolute;

width:82px;

height:28px;

z-index:5;

left: 91px;

top: 565px;

}

#Layer8 {

position:absolute;

width:157px;

height:43px;

z-index:5;

left: 48px;

top: 321px;

}

#Layer9 {

position:absolute;

width:163px;

height:44px;

z-index:6;

left: 47px;

top: 379px;

}

#Layer10 {

position:absolute;

width:155px;

height:44px;

z-index:7;

left: 49px;

top: 592px;

}

-->

</style>

</head>

 

<body>

 

<div id="header">

<h1 align = "center" class="style1"> </h1>

<p align = "center" class="style1"> </p>

<div id="Layer2"><img src="Images/logo.jpg" width="173" height="43"></div>

<p align = "center" class="style1"> </p>

<p align = "center" class="style1"> </p>

<div id="Layer1"><img src="Images/JDS.jpg" width="704" height="79"></div>

 

<form action="ClientFormCheck.php" method="get">

<table width="1156" border="0">

  <tr>

    <td width="1"> </td>

    <td width="66"> </td>

    <td width="108"> </td>

    <td width="62"> </td>

    <td width="204"> </td>

    <td width="195"> </td>

    <td width="16"> </td>

    <td width="161"> </td>

    <td width="284"> </td>

  </tr>

  <tr>

    <td height="68"> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td><div id="Layer6"><img src="Images/Symbol.jpg" width="135" height="129"></div></td>

  </tr>

  <tr>

    <td height="32"> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td>

      <label></label>

      <div id="Layer5"><span class="style3">Client Enquiry Form</span></div>

    <td height="32">

    <td> </td>

    <td> </td>

    <td width="17"> </td>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20"><span class="style1">Issue Title</span></td>

    <td height="20"><input name="issuetitle" type="text" id="issuetitle" value="" size="30"></td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td>

      <label></label>

    <td height="20"><span class="style1">Date of Submission </span></td>

    <td height="20"><input name="datesubmitted" type="text" disabled="disabled" id="datesubmitted" size="30" value="<?php $date = date("l F j, Y");echo $date;?>"></td>

    <td height="20"> </td>

    <td height="20"><div align="left"><span class="style1">Issue Number </span></div></td>

    <td height="20"><input name="issuenumber" type="text" disabled="disabled" id="issuenumber" size="30">

      <div id="Layer10"><a href="Adminlogout.php"><img src="Images/logOffButton.jpg" width="156" height="44" border="0"></a></div></td>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20" class="style1">Time of Submission </td>

    <td height="20"><input name="timesubmitted2" type="text" disabled="disabled" id="timesubmitted2" size="30" value="<?php $date = date("l F j, Y");echo $date;?>"></td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td><div id="Layer9"><a href="helpscreen.php"><img src="Images/helpbutton.jpg" width="163" height="44" border="0"></a></div></td>

    <td> </td>

    <td height="20"><span class="style1">Client Name </span></td>

    <td height="20"><input name="clientFname" type="text" disabled="disabled" id="clientname" size="30" value="<?php echo $_SESSION['firstname']?>"></td>

    <td height="20"> </td>

    <td height="20"><span class="style1">Team Name </span></td>

    <td height="20"><input name="teamname" type="text" disabled="disabled" id="TeamName" size="30" value="<?php echo $_SESSION['teamname']?>"></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td><div align="center">

      <input name="Reset" type="reset" class="style7" value="Reset">

    </div></td>

    <td> </td>

    <td height="20" class="style1"> </td>

    <td height="20"><input name="clientsurname" type="text" disabled="disabled" id="clientsurname" size="30" value="<?php echo $_SESSION['surname']?>"></td>

    <td height="20"> </td>

    <td height="20"> </td>

    <td height="20"> </td>

  </tr>

  <tr>

    <td height="18"> </td>

    <td> </td>

    <td><div align="center"></div></td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td height="30"> </td>

    <td> </td>

    <td><div align="center">

      <input name="Submit2" type="submit" class="style7" id="Submit2" value="Submit">

    </div></td>

    <td> </td>

    <td><div id="Layer8"><a href="Mainmenu.php"><img src="Images/homepagebutton.jpg" width="161" height="41" border="0"></a></div></td>

    <td><span class="style6">Please select Appropriate System </span></td>

    <td> </td>

    <td> </td>

    <td><span class="style6">Please be accurate as this would hold up buisness Operations </span></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td><div align="center"></div></td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td><span class="style1">System Affected </span></td>

    <td>

      <label>

        <select name="systemaffected" class="style1">

          <option>- - -</option>

          <option>STS</option>

          <option>SDM</option>

          <option>TSS</option>

          <option>TLM</option>

          <option>GCG</option>

          <option>SSR</option>

          <option>CER</option>

        </select>

      </label>

    <td> </td>

    <td><span class="style1">Priority Level </span></td>

    <td>

      <label>

        <select name="prioritylevel" class="style1">

          <option>- - - -</option>

          <option>High</option>

          <option>Medium</option>

          <option>Low</option>

        </select>

      </label>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td><span class="style1">Issue Details </span></td>

    <td>

      <label>

        <textarea name="issuedetails" cols="30"></textarea>

      </label>

    <td> </td>

    <td><span class="style1">Assigned To </span></td>

    <td>

      <label>

        <select name="empName" class="style1" id="analyst">

<option>- - -</option>

<?php

        while($row= mysql_fetch_array($result)){?>

          <option > <?php echo $row['surname']?> </option>

  <?php } ?>

      </select>

 

  </td>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td class="style1">Client ID </td>

    <td><input name="clientID" type="" id="clientID" size="10" value="<?php echo $_SESSION['clientID']?>"></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td class="style1">Employee ID </td>

    <td><input name="employeeID" type="" id="employeeID" size="10" value="1"></td>

  </tr>

  <tr>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

</table>

</form>

</body>

 

 

 

 

 

Link to comment
Share on other sites

this bit here is the code for getting the employees to display on the screen in a drop down, its just getting the right employeeID getting the to the right employee.

 

<select name="empName" class="style1" id="analyst">

      <option>- - -</option>

      <?php

        while($row= mysql_fetch_array($result)){?>

          <option > <?php echo $row['surname']?> </option>

        <?php } ?>

      </select>

Link to comment
Share on other sites

this should get the employees name and id number

 

<?php
  session_start();
  if (isset($_SESSION['username']) == false){
     header("Location:ClientLogin.php");
     exit();
  }
?>

<?php

   require "connect.php";
  $query =  "select * from employee order by surname";
  $result = @mysql_query($query, $connection) 
   or die ("Unable to perform query
$query");
while($row= mysql_fetch_array($result))
{
$employeeName=$row['surname'];
$employeeID=$row['ID'];
}

?>



<?php

  require "connect.php";
  $query1 = "select * from form";
  $result1 = mysql_query($query1, $connection)
  or die ("MySQL Error: ".mysql_error());
  
?>

<head>
<title>Jupiter Development Support</title>
<link href="Images/mystyle.css" rel="stylesheet" type="text/css"> 

<style type="text/css">
<!--
#Layer2 {position:absolute;
  width:200px;
  height:52px;
  z-index:2;
  left: 16px;
  top: 143px;
}
#Layer1 {position:absolute;
  width:200px;
  height:80px;
  z-index:1;
  left: 254px;
  top: 84px;
}
.style1 {font-family: "Copperplate Gothic Bold"}
#Layer3 {
  position:absolute;
  width:200px;
  height:115px;
  z-index:3;
  left: 306px;
  top: 255px;
}
#Layer4 {
  position:absolute;
  width:200px;
  height:115px;
  z-index:3;
  left: 842px;
  top: 200px;
}
.style3 {font-family: "Copperplate Gothic Bold"; font-size: x-large; }
#Layer5 {
  position:absolute;
  width:400px;
  height:36px;
  z-index:3;
  left: 390px;
  top: 207px;
}
.style5 {font-family: "Copperplate Gothic Bold"; font-size: small; }
.style6 {
  font-family: "Comic Sans MS";
  font-size: xx-small;
}
.style7 {   font-family: "Copperplate Gothic Bold";
  font-size: medium;
  font-weight: bold;
}
#Layer6 {
  position:absolute;
  width:137px;
  height:130px;
  z-index:4;
  left: 906px;
  top: 199px;
}
#Layer7 {
  position:absolute;
  width:82px;
  height:28px;
  z-index:5;
  left: 91px;
  top: 565px;
}
#Layer8 {
  position:absolute;
  width:157px;
  height:43px;
  z-index:5;
  left: 48px;
  top: 321px;
}
#Layer9 {
  position:absolute;
  width:163px;
  height:44px;
  z-index:6;
  left: 47px;
  top: 379px;
}
#Layer10 {
  position:absolute;
  width:155px;
  height:44px;
  z-index:7;
  left: 49px;
  top: 592px;
}
-->
</style>
</head>

<body>

<div id="header">
<h1 align = "center" class="style1"> </h1>
<p align = "center" class="style1"> </p>
<div id="Layer2"><img src="Images/logo.jpg" width="173" height="43"></div>
<p align = "center" class="style1"> </p>
<p align = "center" class="style1"> </p>
<div id="Layer1"><img src="Images/JDS.jpg" width="704" height="79"></div>

<form action="ClientFormCheck.php" method="get">
<table width="1156" border="0">
 <tr>
   <td width="1"> </td>
   <td width="66"> </td>
   <td width="108"> </td>
   <td width="62"> </td>
   <td width="204"> </td>
   <td width="195"> </td>
   <td width="16"> </td>
   <td width="161"> </td>
   <td width="284"> </td>
 </tr>
 <tr>
   <td height="68"> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td><div id="Layer6"><img src="Images/Symbol.jpg" width="135" height="129"></div></td>
 </tr>
 <tr>
   <td height="32"> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td>
     <label></label>
     <div id="Layer5"><span class="style3">Client Enquiry Form</span></div>
   <td height="32">
   <td> </td>
   <td> </td>
   <td width="17"> </td>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td height="20"><span class="style1">Issue Title</span></td>
   <td height="20"><input name="issuetitle" type="text" id="issuetitle" value="" size="30"></td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td>
     <label></label>
   <td height="20"><span class="style1">Date of Submission </span></td>
   <td height="20"><input name="datesubmitted" type="text" disabled="disabled" id="datesubmitted" size="30" value="<?php $date = date("l F j, Y");echo $date;?>"></td>
   <td height="20"> </td>
   <td height="20"><div align="left"><span class="style1">Issue Number </span></div></td>
   <td height="20"><input name="issuenumber" type="text" disabled="disabled" id="issuenumber" size="30">
     <div id="Layer10"><a href="Adminlogout.php"><img src="Images/logOffButton.jpg" width="156" height="44" border="0">[/url]</div></td>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td height="20" class="style1">Time of Submission </td>
   <td height="20"><input name="timesubmitted2" type="text" disabled="disabled" id="timesubmitted2" size="30" value="<?php $date = date("l F j, Y");echo $date;?>"></td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td><div id="Layer9"><a href="helpscreen.php"><img src="Images/helpbutton.jpg" width="163" height="44" border="0">[/url]</div></td>
   <td> </td>
   <td height="20"><span class="style1">Client Name </span></td>
   <td height="20"><input name="clientFname" type="text" disabled="disabled" id="clientname" size="30" value="<?php echo $_SESSION['firstname']?>"></td>
   <td height="20"> </td>
   <td height="20"><span class="style1">Team Name </span></td>
   <td height="20"><input name="teamname" type="text" disabled="disabled" id="TeamName" size="30" value="<?php echo $_SESSION['teamname']?>"></td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td><div align="center">
     <input name="Reset" type="reset" class="style7" value="Reset">
   </div></td>
   <td> </td>
   <td height="20" class="style1"> </td>
   <td height="20"><input name="clientsurname" type="text" disabled="disabled" id="clientsurname" size="30" value="<?php echo $_SESSION['surname']?>"></td>
   <td height="20"> </td>
   <td height="20"> </td>
   <td height="20"> </td>
 </tr>
 <tr>
   <td height="18"> </td>
   <td> </td>
   <td><div align="center"></div></td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
 </tr>
 <tr>
   <td height="30"> </td>
   <td> </td>
   <td><div align="center">
     <input name="Submit2" type="submit" class="style7" id="Submit2" value="Submit">
   </div></td>
   <td> </td>
   <td><div id="Layer8"><a href="Mainmenu.php"><img src="Images/homepagebutton.jpg" width="161" height="41" border="0">[/url]</div></td>
   <td><span class="style6">Please select Appropriate System </span></td>
   <td> </td>
   <td> </td>
   <td><span class="style6">Please be accurate as this would hold up buisness Operations </span></td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td><div align="center"></div></td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td><span class="style1">System Affected </span></td>
   <td>
     <label>
       <select name="systemaffected" class="style1">
         <option>- - -</option>
         <option>STS</option>
         <option>SDM</option>
         <option>TSS</option>
         <option>TLM</option>
         <option>GCG</option>
         <option>SSR</option>
         <option>CER</option>
       </select>
     </label>
   <td> </td>
   <td><span class="style1">Priority Level </span></td>
   <td>
     <label>
       <select name="prioritylevel" class="style1">
         <option>- - - -</option>
         <option>High</option>
         <option>Medium</option>
         <option>Low</option>
       </select>
     </label>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td><span class="style1">Issue Details </span></td>
   <td>
     <label>
       <textarea name="issuedetails" cols="30"></textarea>
     </label>
   <td> </td>
   <td><span class="style1">Assigned To </span></td>
   <td>
     <label>
       <select name="empName" class="style1" id="analyst">
     <option>- - -</option>
     <?php
         <option > <?php echo $employeeName?> </option>
        <?php } ?>
     </select>
  
 </td>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td class="style1">Client ID </td>
   <td><input name="clientID" type="" id="clientID" size="10" value="<?php echo $_SESSION['clientID']?>"></td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td class="style1">Employee ID </td>
   <td><input name="employeeID" type="" id="employeeID" size="10" value= <?php echo $employeeID?></td>
 </tr>
 <tr>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
   <td> </td>
 </tr>
</table>
</form>
</body>


Link to comment
Share on other sites

im afraid this code doesnt work, im still not picking up the employeeID.

 

Trying to make it sound more simpler -

 

mark = 1

Tom = 2

Harry = 3

 

If i choose mark from the drop down, then in my hidden field should display 1 (empID of mark), but not working.

Link to comment
Share on other sites

right the code below should put create a drop down list for the employee surname. Along with the surname there is thire ID number.

<?php
   session_start();
   if (isset($_SESSION['username']) == false){
      header("Location:ClientLogin.php");
      exit();
   }
?>

<?php

    require "connect.php";
   $query =  "select * from employee order by surname";
   $result = @mysql_query($query, $connection) 
    or die ("Unable to perform query
$query");
while($row= mysql_fetch_array($result))
{
$employeeName=$row['surname'];
$employeeID=$row['ID'];
}

?>



<?php

   require "connect.php";
   $query1 = "select * from form";
   $result1 = mysql_query($query1, $connection)
   or die ("MySQL Error: ".mysql_error());
   
?>

<head>
<title>Jupiter Development Support</title>
<link href="Images/mystyle.css" rel="stylesheet" type="text/css"> 

<style type="text/css">
<!--
#Layer2 {position:absolute;
   width:200px;
   height:52px;
   z-index:2;
   left: 16px;
   top: 143px;
}
#Layer1 {position:absolute;
   width:200px;
   height:80px;
   z-index:1;
   left: 254px;
   top: 84px;
}
.style1 {font-family: "Copperplate Gothic Bold"}
#Layer3 {
   position:absolute;
   width:200px;
   height:115px;
   z-index:3;
   left: 306px;
   top: 255px;
}
#Layer4 {
   position:absolute;
   width:200px;
   height:115px;
   z-index:3;
   left: 842px;
   top: 200px;
}
.style3 {font-family: "Copperplate Gothic Bold"; font-size: x-large; }
#Layer5 {
   position:absolute;
   width:400px;
   height:36px;
   z-index:3;
   left: 390px;
   top: 207px;
}
.style5 {font-family: "Copperplate Gothic Bold"; font-size: small; }
.style6 {
   font-family: "Comic Sans MS";
   font-size: xx-small;
}
.style7 {   font-family: "Copperplate Gothic Bold";
   font-size: medium;
   font-weight: bold;
}
#Layer6 {
   position:absolute;
   width:137px;
   height:130px;
   z-index:4;
   left: 906px;
   top: 199px;
}
#Layer7 {
   position:absolute;
   width:82px;
   height:28px;
   z-index:5;
   left: 91px;
   top: 565px;
}
#Layer8 {
   position:absolute;
   width:157px;
   height:43px;
   z-index:5;
   left: 48px;
   top: 321px;
}
#Layer9 {
   position:absolute;
   width:163px;
   height:44px;
   z-index:6;
   left: 47px;
   top: 379px;
}
#Layer10 {
   position:absolute;
   width:155px;
   height:44px;
   z-index:7;
   left: 49px;
   top: 592px;
}
-->
</style>
</head>

<body>

<div id="header">
<h1 align = "center" class="style1"> </h1>
<p align = "center" class="style1"> </p>
<div id="Layer2"><img src="Images/logo.jpg" width="173" height="43"></div>
<p align = "center" class="style1"> </p>
<p align = "center" class="style1"> </p>
<div id="Layer1"><img src="Images/JDS.jpg" width="704" height="79"></div>

<form action="ClientFormCheck.php" method="get">
<table width="1156" border="0">
  <tr>
    <td width="1"> </td>
    <td width="66"> </td>
    <td width="108"> </td>
    <td width="62"> </td>
    <td width="204"> </td>
    <td width="195"> </td>
    <td width="16"> </td>
    <td width="161"> </td>
    <td width="284"> </td>
  </tr>
  <tr>
    <td height="68"> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td><div id="Layer6"><img src="Images/Symbol.jpg" width="135" height="129"></div></td>
  </tr>
  <tr>
    <td height="32"> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td>
      <label></label>
      <div id="Layer5"><span class="style3">Client Enquiry Form</span></div>
    <td height="32">
    <td> </td>
    <td> </td>
    <td width="17"> </td>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td height="20"><span class="style1">Issue Title</span></td>
    <td height="20"><input name="issuetitle" type="text" id="issuetitle" value="" size="30"></td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td>
      <label></label>
    <td height="20"><span class="style1">Date of Submission </span></td>
    <td height="20"><input name="datesubmitted" type="text" disabled="disabled" id="datesubmitted" size="30" value="<?php $date = date("l F j, Y");echo $date;?>"></td>
    <td height="20"> </td>
    <td height="20"><div align="left"><span class="style1">Issue Number </span></div></td>
    <td height="20"><input name="issuenumber" type="text" disabled="disabled" id="issuenumber" size="30">
      <div id="Layer10"><a href="Adminlogout.php"><img src="Images/logOffButton.jpg" width="156" height="44" border="0">[/url]</div></td>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td height="20" class="style1">Time of Submission </td>
    <td height="20"><input name="timesubmitted2" type="text" disabled="disabled" id="timesubmitted2" size="30" value="<?php $date = date("l F j, Y");echo $date;?>"></td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td><div id="Layer9"><a href="helpscreen.php"><img src="Images/helpbutton.jpg" width="163" height="44" border="0">[/url]</div></td>
    <td> </td>
    <td height="20"><span class="style1">Client Name </span></td>
    <td height="20"><input name="clientFname" type="text" disabled="disabled" id="clientname" size="30" value="<?php echo $_SESSION['firstname']?>"></td>
    <td height="20"> </td>
    <td height="20"><span class="style1">Team Name </span></td>
    <td height="20"><input name="teamname" type="text" disabled="disabled" id="TeamName" size="30" value="<?php echo $_SESSION['teamname']?>"></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td><div align="center">
      <input name="Reset" type="reset" class="style7" value="Reset">
    </div></td>
    <td> </td>
    <td height="20" class="style1"> </td>
    <td height="20"><input name="clientsurname" type="text" disabled="disabled" id="clientsurname" size="30" value="<?php echo $_SESSION['surname']?>"></td>
    <td height="20"> </td>
    <td height="20"> </td>
    <td height="20"> </td>
  </tr>
  <tr>
    <td height="18"> </td>
    <td> </td>
    <td><div align="center"></div></td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td height="30"> </td>
    <td> </td>
    <td><div align="center">
      <input name="Submit2" type="submit" class="style7" id="Submit2" value="Submit">
    </div></td>
    <td> </td>
    <td><div id="Layer8"><a href="Mainmenu.php"><img src="Images/homepagebutton.jpg" width="161" height="41" border="0">[/url]</div></td>
    <td><span class="style6">Please select Appropriate System </span></td>
    <td> </td>
    <td> </td>
    <td><span class="style6">Please be accurate as this would hold up buisness Operations </span></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td><div align="center"></div></td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td><span class="style1">System Affected </span></td>
    <td>
      <label>
        <select name="systemaffected" class="style1">
          <option>- - -</option>
          <option>STS</option>
          <option>SDM</option>
          <option>TSS</option>
          <option>TLM</option>
          <option>GCG</option>
          <option>SSR</option>
          <option>CER</option>
        </select>
      </label>
    <td> </td>
    <td><span class="style1">Priority Level </span></td>
    <td>
      <label>
        <select name="prioritylevel" class="style1">
          <option>- - - -</option>
          <option>High</option>
          <option>Medium</option>
          <option>Low</option>
        </select>
      </label>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td><span class="style1">Issue Details </span></td>
    <td>
      <label>
        <textarea name="issuedetails" cols="30"></textarea>
      </label>
    <td> </td>
    <td><span class="style1">Assigned To </span></td>
    <td>
      <label>
        <select name="empName" class="style1" id="analyst">
      <option>- - -</option>
      <?php
          <option > <?php echo $employeeName." ".$employeeID?> </option>
         <?php } ?>
      </select>
   
  </td>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td class="style1">Client ID </td>
    <td><input name="clientID" type="" id="clientID" size="10" value="<?php echo $_SESSION['clientID']?>"></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>
</form>
</body>

 

Then in script where you process the form you can seperate that dataout like this

$employee  = $_POST['empName']
$pieces = explode(" ", $employee);
echo $employee[0]; // this will be the employee name
echo $employee[1]; // this will be the employee ID

 

 

Link to comment
Share on other sites

I get an error message saying

 

 

Parse error: syntax error, unexpected '<' in C:\wamp\www\HelpDesk\ClientForm.php on line 349

 

Its not liking his bit of code

 

<?php

          <option> <?php echo $surname." ".$employeeID?> </option>

        <?php } ?>

      </select>

Link to comment
Share on other sites

its taken away that particular error message but this appears

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\HelpDesk\ClientForm.php on line 14

 

Which i presume is reffering to this line..

 

<?php

session_start();

if (isset($_SESSION['username']) == false){

header("Location:ClientLogin.php");

exit();

}

 

 

    require "connect.php";

$query =  "select * from employee order by surname";

$result = @mysql_query($query, $connection)

    or die ("Unable to perform query<br>$query");

 

while($row= mysql_fetch_array($result2))

{

$surname=$row['surname'];

$employeeID=$row['employeeID'];

}

 

 

 

 

require "connect.php";

$query1 = "select * from form";

$result1 = mysql_query($query1, $connection)

or die ("MySQL Error: ".mysql_error());

 

?>

 

 

Link to comment
Share on other sites

Sorry my mistake, i have found the error.

 

But this is not quite what im trying to find out.

 

In this code you gave me -

 

<option> <?php echo $surname." ".$employeeID;?> </option>

 

i dont want the employeeID displayed at the same time as the surname.

 

i need the employeeID displayed in another box so when a surname has been selected from the drop down box, the ID relating to that person is displayed in another box.

 

Thanks

 

Link to comment
Share on other sites

basically in summary, i want to select a person from a drop down box and want the ID of that chosen person to be added to the database.

 

e.g

 

mark = 1

Tom = 2

Harry = 3

 

If i choose mark from the drop down, then 1 (empID of mark) , should be added to the DB but not working.

 

Link to comment
Share on other sites

Sorry... Had to run out of town...

 

loop through the dropdown list like this.

 

<option value ="<?php echo$employeeID;?>"><?php echo $surname;?></option>

 

Also when you do the query just query for the the ID or query for more specific terms instead of returning the whole database(select *). Try and use indexed fields. When your db gets bigger it will be faster that way.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.