...

View Full Version : one dropdown works other two do not



bufhal
04-23-2004, 04:21 PM
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,
:p
Bufhal

sad69
04-23-2004, 07:07 PM
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.

bufhal
04-23-2004, 09:09 PM
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
:confused:
Bufhal

sad69
04-23-2004, 09:21 PM
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.

bufhal
04-23-2004, 09:40 PM
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?

bufhal
04-23-2004, 09:42 PM
if you go to the link I sent, and click on the different agencies, no results come back except Univera..very weird. :confused:

sad69
04-23-2004, 10:23 PM
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.

bufhal
04-23-2004, 11:04 PM
can you show me, when you get a chance, the code I need for the dropdowns to access a MySQL database? :o

bufhal
04-23-2004, 11:09 PM
Here are the files. If you have a chance in the next few days, can you take a look?
Thank for your help..
bufhal

sad69
04-23-2004, 11:12 PM
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.

bufhal
04-25-2004, 07:01 PM
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

sad69
04-26-2004, 02:49 AM
Something like this?


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.

bufhal
04-26-2004, 03:03 PM
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. :confused:
I am going to use mysqlfront to admin the database..
Thanks,
bufhal

sad69
04-26-2004, 06:34 PM
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:


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:


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.

bufhal
04-26-2004, 07:58 PM
thank you.. I will work with it and see if I can get anywhere.
Thanks for your time, sad69..
bufhal :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum