Guest Posted February 2, 2010 Share Posted February 2, 2010 <html> <body> <table width="100%" align="center"> <tr><td> <?php $conn=odbc_connect('dsn','un','pw'); if (!$conn) {exit("Connection Failed: " . $conn);} //we've failed the connection $sql="SELECT * FROM divisional_office WHERE name='office1' OR name='office2' OR name='office3' ORDER BY name"; //your query string $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} // some SQL error echo "<select name='someoffice'>"; while (odbc_fetch_row($rs)) //iterates through each database row it's fetched { $officename=odbc_result($rs,"name"); //change to whatever you want, this will grab the results echo "<option>$officename</option>"; } echo "</select>"; echo "</td><td>"; $sql="SELECT * FROM staff"; //your query string $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} // some SQL error echo "<select name='somename'>"; while (odbc_fetch_row($rs)) //iterates through each database row it's fetched { $compname=odbc_result($rs,"first_name"); //change to whatever you want, this will grab the results $conname=odbc_result($rs,"last_name"); echo "<option>$compname $conname</option>"; } odbc_close($conn); echo "</select>"; echo "</td></tr></table>"; ?> </body> </html> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/190690-php-help-needed-please/ Share on other sites More sharing options...
schilly Posted February 2, 2010 Share Posted February 2, 2010 whats the problem? Quote Link to comment https://forums.phpfreaks.com/topic/190690-php-help-needed-please/#findComment-1005651 Share on other sites More sharing options...
wildteen88 Posted February 2, 2010 Share Posted February 2, 2010 And? What is the problem? Just posting your code is not going to yield you any helpful replies. Quote Link to comment https://forums.phpfreaks.com/topic/190690-php-help-needed-please/#findComment-1005652 Share on other sites More sharing options...
Guest Posted February 2, 2010 Share Posted February 2, 2010 My bad.... it was a typo.. Well, the code is above. Here's the question that was supposed to be posted with it: Okay...I have one more task in this form I've been working on & I can't seem to get it working so I ask the experts for some HELP! I've attached the code below & it works fine. When I go to the .php page I get two drop down boxes. The first one is pulls data from my ODBC connection from the DIVISIONAL_OFFICE table & the NAME column. The second drop down box pulls data via the ODBC connection from a table named STAFF & the columns are FIRST_NAME & LAST_NAME. With that said, in the first drop down bow that pulls office1, office2, and office3, I'd like to be able to choose office2 & after I choose it, the drop down box pulling data from the NAME table in the DIVISIONAL_OFFICE table will only show the users that is in office2 and so on... The ODBC database can determine which staff member belongs to which office by looking at the column LOC_CODE from within the STAFF table. Any help will be GREATLY appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/190690-php-help-needed-please/#findComment-1005659 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.