SunQuest
 
           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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old January 7th, 2003, 03:59 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
Code Alteration Help Needed!

Hi,


I have a drop down menu that pulls out information from a mysql dbase, using the following code and displays the results on a results page...


<?php
include "config.php";

$db = mysql_connect ($Host, $User, $Password);
mysql_select_db ($DBName) or die ("Cannot connect to database");
/* We have now connected, unless you got an error message */

$SQL = "SELECT id, areas, towns, zip FROM houses";
$myResult = mysql_query($SQL, $db);
while(list($id, $areas, $towns, $zip) = mysql_fetch_array($myResult))
{
$menuOne .= "<option value=\"$areas\">$areas</option>\r";
$menuTwo .= "<option value=\"$towns\">$towns</option>\r";
$menuThree .= "<option value=\"$zip\">$zip</option>\r";
$menuFour .= "<option value=\"$id\">$id</option>\r";
}
mysql_close($db);

echo "<form action=\"srchtest1.php\" method=\"POST\">\r";
echo "<select name=\"fieldOne\">$menuOne</select>\r";
echo "<select name=\"fieldTwo\">$menuTwo</select>\r";
echo "<select name=\"fieldThree\">$menuThree</select>\r";
echo "<input type=\"Submit\" name=\"Submit\" value=\"Submit\">\r";
"<INPUT TYPE=\"HIDDEN\" NAME=\"id\" value=$menuFour>\r";
echo "</form>\r";


?>


- I would like to make a change whereby I add in a text value at the top of every drop down, in this case 'All Areas', 'All Towns', 'All Zips'. So that the user could just choose a selection from one drop down if they wanted to, leaving the others as they are. So fro example they could choose 'South East' for the area, leaving towns and zip to display all towns & all zips in the results page for 'South East'.
Currently the user has to select a town and zip as well..

Not sure if I've explained this very well, but I need some additional code to add in the new selections to the drop down and some code for the results page to recognise that it has been selected and display all the entries for the new fields as applicable.

Thanks.

Reply With Quote
  #2  
Old January 7th, 2003, 04:22 AM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
So, you are looking to display all area info for a particular geographical area. Example ->

I choose a state, lets say Maryland. When I choose the area (southeast), on the next selection boxes or page with selection boxes you want to have all the cities and zip codes within those cities only, correct?
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #3  
Old January 7th, 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
Basically yes.

I'm new to php and am just getting to grips with it... for information my current results page (srchtest1.php) is like so.

<?

include "config.php";

if ($Submit) // perform search only if a string was entered.
{
$db = mysql_connect ($Host, $User, $Password);
mysql_select_db ($DBName) or die ("Cannot connect to database");

$srch="%".$Submit."%";
$query = "select * from houses WHERE areas LIKE '$fieldOne' || towns LIKE '$fieldTwo' || zip LIKE '$fieldThree' ";

$result = mysql_db_query("stevesims", $query);

if ($result)
{
echo "Here are the results:<br><br>";
echo "<TABLE border = '1' cellspacing = '0' cellpadding ='0' width = '90%' align='center'><tr>
<td align=center bgcolor=#cccc66><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">URL</font></td>
<td align=center bgcolor=#cccc66><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Area</font></td>
<td align=center bgcolor=#cccc66><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Town</font></td>
<td align=center bgcolor=#cccc66><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Post Code</font></td>
</tr>";

while ($r = mysql_fetch_array($result)) { // Begin while

$areas = $r["areas"];
$towns = $r["towns"];
$zip = $r["zip"];
$id = $r["id"];
echo "<tr>
<td><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\"><A HREF=\"../view2c.php?id=$id\">View Property</A></font></td>
<td><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">$areas</font></td>
<td><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">$towns</font></td>
<td><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">$zip</font></td></tr>
";
} // end while
echo "</table>";
} else { echo "problems...."; }
} else {
echo "Search string is empty. <br> Go back and type a string to search";
}

?>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Code Alteration Help Needed!


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 | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway