Jump to content

inserting dropdown list in proper place in form


jvandal

Recommended Posts

I added a dropdown field for field named subject.  It displays at the bottom of the form. It doesn't add the value to the field , leaving it blank

Any help will be appreciated

jvandal

//************ form with select drop down table *******************

 

 

<?php

session_start();

if(!isset($_SESSION['iid']))

    $_SESSION['iid'] =  1;

$myid = $_SESSION['iid'];

echo "views = ". $_SESSION['iid'];

 

echo "this id is $myid<br>";

$conn = @mysql_connect("localhost", "root", "") or die(mysql_error());

    echo ("Connect to HOST<br>");

$db = @mysql_select_db("usadb",$conn);

    echo ("connect to DB<br>");

 

?>

 

<HTML>

<HEAD>

<center><h1>Works Input Form</h1></center>

<TITLE>INsert Form</TITLE>

</HEAD>

<body>

    <form action="<?php echo( $self ); ?>" method="post">

<P><strong>Subject/Person/:</strong><br>

//************ select drop down table *******************

//*************************************************

<?php

$query="SELECT titlex,id FROM subjects";

 

/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

 

$result = mysql_query ($query);

echo "<select name=subjects value=''>Subject Name</option>";

// printing the list box select command

//************ end select drop down table *******************

//***************************************************

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt

echo "<option value=$nt[id]>$nt[titlex]</option>";

/* Option values are added by looping through the array */

}

echo "</select>";// Closing of list box

?>

//************ field to be replaced select drop down table **********************************************

<input type= text name= "subjectid" size=10 >

<input type= text name= "personid" size=10></p>

   

   

    <P><strong>Title/Startdate/Endhdate:</strong><br>

    <input type= text name= "title" size=50 >

   

<P><strong>Start:</End Date ><br>

<input type= text name= "startday" size=10>

<input type= text name= "startmonth" size=10>

    <input type= text name= "startyear" size=10>

 

<input type= text name= "endday" size=10>

<input type= text name= "endmonth" size=10>

<input type= text name= "endyear" size=10>

 

<P><strong>Owner\Manager:</strong><br>

<input type= text name= "owner" size=30 >

<input type= text name= "manager" size=5 >

 

 

<P><strong>Salery:</strong><br>

<input type= text name= "salery" size=30 >

 

 

<p><input type="submit" value="Add Works"></p>

 

<p><a href="Adminmenu.htm?<?php echo( SID );?>">Back to Menu</a>

<p><a href="../ushowworks.php?<?php echo( SID );?>">Back toPersons</a>

 

></p>

</FORM>

 

 

 

 

<?PHP

 

  if ($_POST[subjectid] || $_POST[title]) {

//************ replace subject field with $nt[id} *******************

//**********************************************************

  $add_master = "insert into works values ('', '$nt[id]', $myid,     '$_POST[title]', '$_POST[startday]', '$_POST[startmonth]', '$_POST[startyear]', '$_POST[endday]','$_POST[endmonth]','$_POST[endyear]', '$_POST[owner]', '$_POST[manage]',

'$_POST[salery]')";

  $rs =  mysql_query($add_master);

echo ("past sql<br>");

  if ($rs) {echo ("added to work table<br>");

} else {

  echo ("NOT added to work able<br>");

}

}

?>

</body>

</HTML>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.