|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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"; } ?> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Code Alteration Help Needed! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|