<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[PHP Forums - PHP script to select state]]></title>
		<link>http://phpforums.org/topic29-php-script-to-select-state.html</link>
		<description><![CDATA[The most recent posts in PHP script to select state.]]></description>
		<lastBuildDate>Fri, 06 Aug 2010 07:29:32 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: PHP script to select state]]></title>
			<link>http://phpforums.org/post72.html#p72</link>
			<description><![CDATA[<p>You can place a select box with all the available states in contacts and populate it in a select box.&nbsp; Then after that based on the selected values pass query to the database</p><div class="codebox"><pre><code>&lt;select name=&quot;state&quot;&gt;
&lt;?php
$sql   =  &quot;SELECT DISTINCT ( state ) FROM contacts ORDER BY state&quot;;
$res = mysql_query( $sql ) or die( mysql_error());
while( $row = mysql_fetch_object( $res ) ){
           echo &#039;&lt;option = &#039;&quot;. $row-&gt;state .&quot;&#039;&gt;&#039;. $row-&gt;state .&#039;&lt;/option&gt;&#039;;
}
?&gt;
&lt;/select&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;search&quot;&gt;</code></pre></div><p>Then in the landing page do the following code<br /></p><div class="codebox"><pre><code>&lt;?php 
if( isset( $_POST[&#039;state&#039;] ) ){
       $sql = &quot;SELECT * FROM contacts WHERE state = &quot;&quot;.  $_POST[&#039;state&#039;] .&quot;&#039;&quot;;
       //Remaining Operations
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (aneeshrp)]]></author>
			<pubDate>Fri, 06 Aug 2010 07:29:32 +0000</pubDate>
			<guid>http://phpforums.org/post72.html#p72</guid>
		</item>
		<item>
			<title><![CDATA[PHP script to select state]]></title>
			<link>http://phpforums.org/post58.html#p58</link>
			<description><![CDATA[<p>I have a database table called contacts with a table in it called addresses. The fields in the addresses table are firstname, lastname, address, city, state, zip, areacode and phonenumber. (The state field is a 2 character text field.) I want to ask the user for a state and then I want to display all the records for that state only. Can anyone help me? </p><p>Thanks, </p><p>Andrew</p>]]></description>
			<author><![CDATA[null@example.com (andrewgrz)]]></author>
			<pubDate>Sat, 12 Jun 2010 03:26:22 +0000</pubDate>
			<guid>http://phpforums.org/post58.html#p58</guid>
		</item>
	</channel>
</rss>

