Jump to content

PHP Help Needed PLEASE


wantabe2

Recommended Posts

<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]

Link to comment
Share on other sites

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.

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.