tress Posted August 21, 2007 Share Posted August 21, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/66064-php-drop-downs/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.