Jump to content

PHP Drop Downs


tress

Recommended Posts

Hi there,

 

Hope someone can help as I am finding it hard trying to get my head around PHP and having to learn what I think is quite complicated stuff rather than the basics because that is what the company want, and they are to cheap to employ someone that knows what they are doing  ;)

 

I have piece of php which pulls data into a drop down menu from a SQL database table

 

this script is called issueinsert.php

 

<?php

// create connection 
$connection = mssql_connect("localhost","sa","password"); 
// test connection 
if (!$connection) 
{ 
echo "Couldn't make a connection!"; 
} 

// select database 
$db = mssql_select_db("nai", $connection); 
// test selection 
if (!$db) 
{ 
echo "Couldn't select database!"; 
} 

$query ="select IssueTypeID, IssueTypeDesc from IssueType";
$result = mssql_query($query, $connection);

while ($row = mssql_fetch_array($result)) $IssueTypeLookup[] = $row;

echo '<SELECT name="dropdown">';
  foreach ($IssueTypeLookup as $c)
  {
    if ($c['id'] == $_GET['id'])
      echo "<OPTION value=\"{$c['IssueTypeID']}\" SELECTED>{$c['IssueTypeDesc']}</OPTION>\n";
    else
      echo "<OPTION value=\"{$c['IssueTypeID']}\">{$c['IssueTypeDesc']}</OPTION>\n";
  }
  echo '</SELECT>';
?>

 

now the form that I was originaly going to use looked like the below and was called Issue.php

 

<form action="issueinsert.php" method="post">
<div class="gray">
<table border="0" cellspacing="0" cellpadding="5">
  <tr>
     <td><strong>IssueID:</strong></td>
     <td><input name="IssueID" type="text" value="" /></td>
  </tr>
  <tr>   
     <td><strong>ContractID:</strong></td>
     <td><input name="ContractID" type="text" value="" /></td>
  </tr>
  <tr>
     <td><strong>IssueTypeDesc:</strong></td>
     <td><input name="IssueTypeDesc" type="text" value="" /></td>
  </tr>

 

My problem is I dont know how to put my drop down onto the html page to populate my database and to replace the currently typed in IssueTypeDesc value.

 

Could someone please help?

 

Thanks tress

 

EDIT: Please use the [code][/code] tags.

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.