Forum Moderators: coopster

Message Too Old, No Replies

Hiding Search Form Fields

         

bzzrd2

3:40 pm on Sep 19, 2005 (gmt 0)

10+ Year Member



Hi
I need to hide a couple of fields in the search for below. The idea is to have the customer select the City button of their choice which will take them to information for that city. The form works fine, just need to be able to hide the city/country fields and be able to enter them in the script for each city/country. Thanks!

<?
include_once "myconnect.php";
{
?>
<form name="form1" method="post" action="showcategory.php" >

<input name="location" type="text" id="location" value="My City" size="10">

<select name="country" size="1">
<option selected value="">All Countries</option>

<?

$rs_t_query=mysql_query ("select * from mysqldatabse_country order by country");
while ($rs_t=mysql_fetch_array($rs_t_query))
{
?>
<option value="<? echo $rs_t["id"];?>"><? echo $rs_t["country"] ;?></option>
<?
}
?>
</select>

<input type="submit" name="Submit" value="My City">
<input name="show_save" type="hidden" id="show_save" value="yes">

</font></td>

</tr>

</form>

<?
}// end main

?>

jatar_k

6:00 pm on Sep 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



are you setting a var that could be used to show/hide the form elements?

bzzrd2

7:06 pm on Sep 20, 2005 (gmt 0)

10+ Year Member



jatar_k
What I'm using is what you see. I'm very new to PHP / MySql so any help is appreciated. Just want to hide everything and display the search button with the city name on it. I want to have multiple links or City buttons on the same page so when a user navigates to their city it will bring back any results for that city/country. If this won't work I need to find an alternative. I'm even OK with a link that will do the search if that's possible.

jatar_k

7:35 pm on Sep 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



alright then I may need some clarification, I don't understand the logic you are trying to acheive

>> The idea is to have the customer select the City button of their choice which will take them to information for that city.

ok that makes sense by itself

>> The form works fine, just need to be able to hide the city/country fields

now I lose it, you want them to select them but you don't want them to see them?

>> and be able to enter them in the script for each city/country.

I don't get that part either.

I'm sorry, i want to help I just really don't understand the flow of what you want to do

bzzrd2

9:07 pm on Sep 20, 2005 (gmt 0)

10+ Year Member



Sorry if I wasn't clear. I'll try again.

Customer navigates from index page through country, state, province, region etc. (html)

Once they get to region I want them to have links, buttons whatever for the city of their choice. Once they select a city it will bring back results as the form I posted does from the mysql database.

I thought maybe I could hide the fields, hard code the country/city and display the button or link. Same thing for each city on the page.

The customer can jump right to the end via a link on the homepage but I wanted this as an alternative and to display some information along the way.

Like this:

Click Country (html) => to Province Page
Select Province (html) => to Region Page
Select Region (html) => to Cities for that Region
Cities:
Toronto
Brampton
Kingston ...etc.

Clicking a City would bring back results from mysql as per the form I posted.

Hope that helps and thanks!

jatar_k

4:08 pm on Sep 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think I get it then

if you are using buttons you should be able to have a hidden form field that contains the country info. I don't know where that is accessible though, is it posted? some var somewhere?

this is the general idea

<form name="somename" action="somescript" method="post">
<input type="hidden" name="country" value="<?php echo $countryvar;?>">
<input type="hidden" name="country" value="<?php echo $cityvar;?>">
<input type="submit" value="<?php echo $cityvar;?>">
</form>

then when it is submitted you will have the country and the city available in the $_POST array

that what you mean?

bzzrd2

9:17 pm on Sep 21, 2005 (gmt 0)

10+ Year Member



Yes, that seems to what I'm looking for however I still can't get it to work right. When I put USA in the country area and a valdid USA city in the city string I still get Canadian and USA Cities coming up. I'm beginning to think I'm thick!

Here's the mysql table. (it's edited down) Canada is Country code 32 and USA is 210. Cities are named. ie: Toronto. I really appreciate the help...

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

--
-- Table structure for table `myXXXXXXXdatabse_members`
--

CREATE TABLE `myXXXXXXXdatabse_members` (
`id` bigint(20) NOT NULL auto_increment,
`c_name` varchar(255) collate latin1_general_ci default NULL,

`city` varchar(255) collate latin1_general_ci default NULL,
`state` varchar(255) collate latin1_general_ci default NULL,
`zip` varchar(50) collate latin1_general_ci default NULL,
`country` varchar(255) collate latin1_general_ci default NULL,

`suspended` varchar(255) collate latin1_general_ci default 'no',
`temp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`signup_on` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=31 ;

This is how I'm setting the page up:
<?
include_once "myconnect.php";
{
?>
<form name="cities" action="showcategory.php" method="post">
<input type="hidden" name="country" value="<?php echo $countryvar;?>">
<input type="hidden" name="country" value="<?php echo $cityvar;?>">
<input type="submit" value="<?php echo $cityvar;?>">
</form>

<?
}// end main

?>

jatar_k

1:39 am on Sep 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the issue is, your form needs to be able to get the country id from somewhere, also the region I assume

have they made a previous selection in a form?
can you parse the url for it?

bzzrd2

2:08 am on Sep 22, 2005 (gmt 0)

10+ Year Member



jatar_k, your code turned the lights on for me. From my original code all I had to do was change:

<input name="location" type="text" id="location" value="My City" size="10">
to:
<input name="location" type="hidden" id="location" value="My City">

and:
<select name="country" size="1"><option selected value="">All Countries</option>

to:
<input name="country" type="hidden" size="1"><option selected value="Country Code Here"></option>

So now when I enter "New York" in the "value="My City""

and for country:
<option selected value="32"></option>

and the button:
<input type="submit" name="Submit" value="New York">

I get a lovely little button showing with nothing else that brings back nothing but posts from New York.

Thank you so much for your time as I learn. You have been very helpful. :-)

jatar_k

2:47 am on Sep 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



nice work