Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    one dropdown works other two do not

    Hello;

    I have three files of fairly lengthy code I am stuck on. In a nutshell, I have three dropdown's which a user can find City, Date or Agency. City is working but Agency and Date are not. The files are index.php (the main webpage with dropdowns, test_view.php, and results.php. I am new to PHP. Attached are the files along with the .dat files for each dropdown. I can post any relevant code if it will help...

    Thank you,

    Bufhal
    Attached Files Attached Files

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you elaborate a little more when you say 'not working'? How is it not working? What is it supposed to do in the first place?

    Sadiq.

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello; thanks for replying..
    There are three dropdown menus Agency, Date and City. I have three cooresponding .dat files that are in alpha-order which a user can click on to get the entire record(s) from the .dats. City is working, but I am new to PHP and cannot get the other two to work correctly.
    Here is the URL of the webpage with dropdowns:

    http://www.immunizewny.org/index.php

    To answer your question of what is not working: Date is not picking up the dates.dat file on the server(that file is in alpha-num oreder and has no 2003 dates). And Agency is only bringing back results for Univera ans is not picking up the agencies.dat file

    Thank you-sad69

    Bufhal

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok...

    So I'm still unclear. 3 drop-downs, city date and agency. All 3 have options. These options are loaded from their respective .dat files.

    So far so good?

    If a particular city is selected, should particular dates show up? Then if a particular date is selected, should particular agencies show up?

    I don't think I understand what you mean by bringing back results from Univera.. well I didn't submit the form because it almost didn't matter what I selected from one drop down as the next selection seemed to zero out my other selections.

    I think this is partly a Javascript problem, and you may want to post in the Javascript forum those questions.

    Either way, I still don't think I understand what's supposed to be happening. Like let's say the user picks a Univera. What's supposed to happen?

    Sadiq.

  • #5
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If one picks a certain agency from the dropdown, they should get back all of that agency's listings along with the other info in that record..for instance..
    Here is a typical record:
    2<|>St. Theresa Avila<|>5771 Buell St.<|>Akron<|>Parish Hall<|>Catholic Health System<|>11/12/04<|>Wedns <|>9:00 am to 1:00 pm<|> 14001<|>716-542-9103<|>Gary Smith

    The same for Date. When one chooses a specific date, the whole reord will come back.
    Were you able to get results from the dropdowns on the link?

  • #6
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you go to the link I sent, and click on the different agencies, no results come back except Univera..very weird.

  • #7
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Lol, my popup blocker wasn't opening your windows on selecting your drop downs.

    I'd suggest you move to a database (MySQL) rather than using the text file. It's easier to work with and will keep your data more organized.

    Other than that, I'm not sure what the problem is. I'd have to take a look at those files of yours, but I don't think I'll get a chance today.. hopefully someone else can help you. But I still think you should go the database route as it will save you grief in the long run.

    Sadiq.

  • #8
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can you show me, when you get a chance, the code I need for the dropdowns to access a MySQL database?

  • #9
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here are the files. If you have a chance in the next few days, can you take a look?
    Thank for your help..
    bufhal
    Attached Files Attached Files

  • #10
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Check out this link:
    http://forums.devshed.com/showthread.php?p=596761

    You're going to need to install MySQL and setup your database with the fields and whatever. After you install MySQL, try and get phpMyAdmin to easily setup your database.

    You're going to need tables (or maybe just one table..) with your data from your textfiles split into different fields.

    That way when a user selects an item from the Date drop-down, you just need to select records from your database with that Date.

    Good luck and have fun with it!
    Sadiq.

  • #11
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Sad69
    the database will have one table "agency" and 11 columns for the following:
    City Date Day Time Agency_name Location Building/room Street Zip Phone_num contact_person
    The dropdowns will be City, Agency and Date. When one clicks the dropdown, all the cities will be under on, dates another and agencies the last. When one clicks on one of the items ALL columns(11 items above) should show up in a pop-up window that coorespond with that particular query.
    Can you help me with the initail code? Here is what I have as a guide...


    PHP:
    --------------------------------------------------------------------------

    mysql_connect('localhost','db_username','db_password');
    mysql_select_db('db_name');

    $query = mysql_query("SELECT column FROM table") or die(mysql_error());

    while($row = mysql_fetch_array($query))
    {
    echo $row["column"];
    }

    Thanks for any help..
    bufhal

  • #12
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Something like this?
    PHP Code:
    mysql_connect('localhost','db_username','db_passwo rd');
    mysql_select_db('db_name');

    $query mysql_query("SELECT * FROM table") or die(mysql_error());

    while(
    $row mysql_fetch_array($query)) {
     foreach(
    $row as $column=>$value) {
      echo 
    $value;
     }
     
     echo 
    "<br>"//to go to the next line

    Not too sure what else you're asking me for but play with that code and the formatting. See what your output is and just adjust your php code as necessary.

    Good luck,
    Sadiq.

  • #13
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    each click in the dropdowns needs to fetch the entire column(s) with the cooresponding records and print into popup(please see link and try Cities dropwdown to see what I need this to do)

    http://www.immunizewny.org/index.php

    I will have the database set up later today. Will your code do that for each dropdown? Will it print results into popup?
    That's really what I am cluless about and need help, Sad69.
    I am going to use mysqlfront to admin the database..
    Thanks,
    bufhal

  • #14
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok.. no my code won't quite do that. Right now it's going to print off EVERY record in your database.

    I think we're looking more at something like this:
    PHP Code:
     mysql_connect('localhost','db_username','db_passwo   rd'); 
     
    mysql_select_db('db_name'); 

     
    $result mysql_query("SELECT * FROM agency WHERE $columnName='".$columnValue."'") or die(mysql_error()); 

     while(
    $row mysql_fetch_array($result)) { 
      foreach(
    $row as $column=>$value) { 
       echo 
    $value
      } 

      echo 
    "<br>"//to go to the next line 
     

    So before executing this code, you need to setup two variables: $columnName and $columnValue. $columnName should equal the name of your column, which is also the type of dropdown (so like date or city or something..) and $columnValue should be assigned the value of the dropdown.

    This way it limits the records printed out accordingly.

    I don't know if you know how to populate your dropdowns, but you'd do something like this:
    PHP Code:
     mysql_connect('localhost','db_username','db_passwo   rd'); 
     
    mysql_select_db('db_name'); 

     
    $result mysql_query("SELECT $columnName FROM agency") or die(mysql_error()); 

     echo 
    "<select name='sel_".$columnName."'>"//name this whatever you want

     
    while($row mysql_fetch_array($result)) { 
      echo 
    "<option value='".$row[$columnName]."'>".$row[$columnName]."</option>";  
     }
     
     echo 
    "</select>"
    Hope that works out for you. You'll probably have to change it up a little to work for you.

    Good luck,
    Sadiq.

  • #15
    New Coder
    Join Date
    Apr 2004
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you.. I will work with it and see if I can get anywhere.
    Thanks for your time, sad69..
    bufhal


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •