[thelist] Select - forms

Andrew andrew at humanbehaviour.co.uk
Mon Mar 10 09:15:01 CST 2003


>
>Andrew, post some code or a page, I can't make heads or tails of what
>you said - not sure if anyone else will be able to either.
>
>Tom


ok here is the link if you select Somerset and then nothing except what is
displayed as set of results get returned.

If you then choose any other county the same reults remain there untill you then
hit the submit button again, so there is some type of refresh problem I think or
the form isn't right :(

http://www.punterspower.co.uk/index.php

here is the code:


<!-- Include Left Menu Options Here -->
<table width="146" border="0" cellpadding ="0" cellspacing="0">
 <tr class="navTable"><td class="searchheader" height="18">

You selected


 </td>
</tr>

<tr>
 <td>

<form action='./FindTownsCityCompanies.php' method='POST' name='CompanySearch'>
  <input type='hidden' name='CompanySearch' value='YES' />
  <input type='hidden' name='CompanySearch' value='Simple' />

<?
require("connection.php");

mysql_connect("$DBHost", "$DBUser", "$DBPass") or
        die("could not connect");
    mysql_select_db("$DBName");

echo "<select name=\"CountyID\" size=\"1\" class='menuForm'>";

$result=mysql_query("SELECT County, CountyID FROM county ORDER BY County");
while ($row = mysql_fetch_array($result)) {
  $county_id=$row['CountyID'];
  $county=$row['County'];
  echo "<option value=\"$county_id\"";
  if ($CountyID == $county_id)
    {echo " selected";}
  echo "> $county </option>";
}
echo "</select>";
?>
*tip if you select a different shire click <INPUT TYPE="image" SRC="search.gif"
VALUE="find a company in your city" Name="CompanySearch">.
<br />

now select





<?

echo "<select name=\"CityID\" size=\"1\" class='menuForm'>";

$result=mysql_query("SELECT CountyID, City, CityID FROM city WHERE
CountyID=".$CountyID." ORDER BY City");
while ($row = mysql_fetch_array($result))
    {
        $county_id=$row['CountyID'];
        $city_id=$row['CityID'];
		$city=$row['City'];
echo "<option value=\"$city_id\"> $city </option>";
if ($CountyID == $county_id)
    {echo " selected";}
  echo "> $county </option>";
}
echo "</select>";
?>
<br />

<?
echo "<select name=\"Category\" size=\"1\" class='menuForm'>";

$result=mysql_query("SELECT Category, CategoryID FROM category ORDER BY
Category");
while ($row = mysql_fetch_array($result)) {
echo "<option value=\"$row[CategoryID]\"> $row[Category] </option>";
}
echo "</select>";
?>

 </td>
</tr>

<tr class="navTable">
 <td class="bgColorMid">
  <table cellpadding="0" cellspacing="0" border="0" width="100%">
   <tr>
    <td align="right">

<input class="inputsubmit" type="submit" value="Find Company">
<INPUT TYPE="image" SRC="search.gif" VALUE="find a company in your city"
Name="CompanySearch">

     </tr>
    </table>
   </td>
  </tr>
 </form>
</table>

I thought this might be a bit too big for the thelist hope its ok.

Andrew




More information about the thelist mailing list