General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 31st, 2003, 05:33 AM
steve55 steve55 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: UK
Posts: 44 steve55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to steve55 Send a message via Yahoo to steve55
Using external files to populate a menu.

I am using three text files to populate three drop down menus (areas, towns and post codes) . Each option in the drop down corresponds to a field in a mysql database.

I would like to instigate a search based on the users selections, but am having a problem outputting the results. I have an option for 'all areas', 'all towns' and 'all post codes' and because these aren't fields in the database no results are returned...

How do I write a results page that will display all areas from my database, or all towns etc.. if it is selected?

Hope that makes sense. Here is my drop down menu code:-


<form method=post action="srchtest1.php">
<select name="fieldOne">

<?php
$myfile = file("areas.txt");
$options = sizeof($myfile);

for ($i=0;$i<sizeof($myfile); $i++){
print "<OPTION>".$myfile[$i]."</OPTION>/n";
}
?>

</select>
<br>

<select name="fieldTwo">

<?php
$myfile1 = file("towns.txt");
$options = sizeof($myfile1);

for ($i=0;$i<sizeof($myfile1); $i++){
print "<OPTION>".$myfile1[$i]."</OPTION>/n";
}
?>

</select>
<br>

<select name="fieldThree">

<?php
$myfile2 = file("zip.txt");
$options = sizeof($myfile2);

for ($i=0;$i<sizeof($myfile2); $i++){
print "<OPTION>".$myfile2[$i]."</OPTION>/n";
}
?>

</select>
<br><br>
<input name="Submit" type="Submit" value="Submit">

</form>


and here is an example of one of the text files:-

All Areas
Devon
North Devon
North Cornwall
Cheshire

----------------------------------------------------------------

An example of the script is here http://www.stevesims.com/jump3.php
-------------------------------------------------------------------

Reply With Quote
  #2  
Old January 31st, 2003, 06:44 AM
vlasblom vlasblom is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Netherlands
Posts: 14 vlasblom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 45 sec
Reputation Power: 0
Post

As far as I can see, the search in your database is an OR construction, probably something like:
Code:
SELECT * FROM table WHERE area=$area OR town=$town OR zipcode=$zipcode
The script that is handling the submission must check for the special value 'All ....' in which case the particular part of the where clause should be omitted.

Why do you use a text file, to define the value to be searched for in a database?
To me it seems to be more straight forward that you create your selection list on the content of the database and simply add the special value 'All ....' to the beginning.

But that reminded me, you already did post such a solution (http://www.devarticles.com/forum/sh...=&threadid=2280).

Are you still having difficulties with that result script?

Regards,

Reply With Quote
  #3  
Old January 31st, 2003, 08:03 AM
steve55 steve55 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: UK
Posts: 44 steve55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to steve55 Send a message via Yahoo to steve55
The solution didn't ever work for 'all areas' or 'all towns' etc...
It works fine otherwise.

The reason I am pulling text files in is that I want the user to be able to update these files through a browser, thus updating the menus...and avoiding any ftp uploading.

So this is a slightly different scenario from the previous one, but I am seeking a solution that would probably work for both of my threads, as I still don't have one.

Reply With Quote
  #4  
Old January 31st, 2003, 08:15 AM
vlasblom vlasblom is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Netherlands
Posts: 14 vlasblom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 45 sec
Reputation Power: 0
Steve,

Using text files is your decission.

When 'all areas', 'all towns' and 'all zips' are submitted your SQL query should be staightforward and probably look like this:
Code:
SELECT * FROM table
Are you still using the same result script?
Please (re)post your script, so I can have a look at it.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Using external files to populate a menu.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT