Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to store selected fields from dropdown list to variables
    primarykey
    data
    text
    <p>I'm unable to store multiple fields selected from dropdown lists in form to variables in PHP using GET syntax. I am doing a search query list data in field based on the selection. </p> <p>HTML code:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form action="search3.php" method="GET"&gt; &lt;Table&gt; &lt;tr&gt; &lt;td&gt;Transaction:&lt;/td&gt; &lt;td&gt; &lt;Select name="Transaction"&gt; &lt;Option value ="Buy"&gt;Buy&lt;/Option&gt; &lt;Option value ="Sell"&gt;Sell&lt;/Option&gt; &lt;Option value ="Rent"&gt;Rent&lt;/Option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;PropertyType:&lt;/td&gt; &lt;td&gt; &lt;Select name="PropertyType"&gt; &lt;Option value ="Land"&gt;Land&lt;/Option&gt; &lt;Option value ="Apartment"&gt;Apartment&lt;/Option&gt; &lt;Option value ="Commercial"&gt;Commercial&lt;/Option&gt; &lt;Option value ="Other"&gt;Other&lt;/Option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Location: &lt;/td&gt; &lt;td&gt; &lt;Select name ="Location"&gt; &lt;Option value ="Mumbai"&gt;Mumbai&lt;/Option&gt; &lt;Option value ="Thane"&gt;Thane&lt;/Option&gt; &lt;Option value ="NaviMumbai"&gt;NaviMumbai&lt;/Option&gt; &lt;Option value ="Other"&gt;Other&lt;/Option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="submit" value="submit"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/Table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>PHP code:</p> <pre><code>$Var2 = $_GET['PropertyType']; $Var3 = $_GET['Location']; $var1 = $_GET['Transaction']; echo $var1; echo $var2; echo $var3; $trimmed1 = trim($var1); //trim whitespace from the stored variable; $trimmed2 = trim($var2); //trim whitespace from the stored variable; $trimmed3 = trim($var3); //trim whitespace from the stored variable; $db = "landshop_clientdata"; $link = mysql_connect('localhost','root'); if (!$link) { die("Couldn't connect to MySQL"); } mysql_select_db($db, $link) or die("Couldn't open $db: ".mysql_error()); $result = mysql_query("SELECT Agent_Ind,Title,firstname,lastname,Phone,email,Transaction,propertyType,Location,Area,Units,AdditionalData FROM clientdata where Transaction ='$trimmed1' AND PropertyType = '$trimmed2' AND Location = '$trimmed3' AND '$trimmed2' AND '$trimmed3") or die("SELECT Error: ".mysql_error()); //$describe = mysql_query("SHOW COLUMNS FROM $table") //$meta = mysql_fetch_field($result); //$fields_array[] = $meta-&gt;name; $num_rows = mysql_num_rows($result); print "There are $num_rows records.&lt;P&gt;"; print "These are records for $trimmed1.&lt;p&gt;"; //$row = mysql_fetch_assoc($result); print "&lt;table width=600 border=1&gt;\n"; //while ($get_info = mysql_fetch_row($result)) //print "&lt;tr&gt;\n"; //foreach ($get_info as $field) //print "&lt;tr&gt;&lt;td&gt;&lt;font face=arial size=3/&gt;name :&lt;/td&gt; &lt;/tr&gt;" //print "&lt;tr&gt;&lt;td&gt;$field&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;"; Print "&lt;th&gt; Agent or Individual&lt;/th&gt; "; Print "&lt;th&gt; Title&lt;/th&gt; "; Print "&lt;th&gt; First Name&lt;/th&gt; "; Print "&lt;th&gt;Last Name&lt;/th&gt;"; Print "&lt;th&gt; Phone&lt;/th&gt; "; Print "&lt;th&gt; Email&lt;/th&gt; "; Print "&lt;th&gt;Transaction&lt;/th&gt;"; Print "&lt;th&gt; Location&lt;/th&gt; "; Print "&lt;th&gt; Area&lt;/th&gt; "; Print "&lt;th&gt; Units&lt;/th&gt; "; Print "&lt;th&gt; Additional_Data_of_Property&lt;/th&gt; "; while($info = mysql_fetch_array( $result )) { print "&lt;tr&gt;\n"; Print "&lt;td&gt;log in to see&lt;/td&gt;\n"; Print "&lt;td&gt;log in to see&lt;/td&gt;\n"; Print "&lt;td&gt;log in to see&lt;/td&gt;\n"; Print "&lt;td&gt;log in to see&lt;/td&gt;\n"; Print "&lt;td&gt;log in to see&lt;/td&gt;\n"; Print "&lt;td&gt;log in to see&lt;/td&gt;\n"; Print "&lt;td&gt;".$info['Transaction'] . " &lt;/td&gt;\n"; Print "&lt;td&gt;".$info['Location'] . "&lt;/td&gt;\n"; Print "&lt;td&gt;".$info['Area'] . "&lt;/td&gt;\n"; Print "&lt;td&gt;".$info['Units'] . "&lt;/td&gt;\n"; Print "&lt;td width '80%'&gt;".$info['AdditionalData'] . "&lt;/td&gt;\n"; print "&lt;/tr&gt;\n"; } print "&lt;/table&gt;\n"; mysql_close($link); echo ("Want to view full contact details\n"); print( '&lt;a href="index_files/logIn.htm"&gt;Login or Register&lt;/a&gt;' ); echo ("Click to return to landshoppe\n"); print( '&lt;a href="index.htm"&gt;Click Me&lt;/a&gt;' ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload