Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>&lt;?php if(isset($_POST['submit'])){ if(isset($_GET['go'])){ // improved the filter to support space and - // Also closed critical security breache (SQL-injection) if(preg_match("/^[a-zA-Z0-9 -]+$/", $_POST['user-entry'])){ $cob=$_POST['user-entry']; $pricerange=$_POST['pricerange']; //connect to the database $db=mysql_connect ("server", "user", "pass") or die (mysql_error()); //-select the database to use $mydb=mysql_select_db("db_name"); switch ($pricerange) { case 2 : $pricerange = " AND Price BETWEEN 21.00 AND 30.00 "; break; case 3 : $pricerange = " AND Price BETWEEN 31.00 AND 50.00 "; break; case 4 : $pricerange = " AND Price BETWEEN 51.00 AND 75.00 "; break; case 5 : $pricerange = " AND Price BETWEEN 76.00 AND 100.00 "; break; case 6 : $pricerange = " AND Price BETWEEN 101.00 AND 200.00 "; break; case 7 : $pricerange = " AND Price &gt; 200.00 "; break; default : $pricerange = " AND Price BETWEEN 10.00 AND 20.00 "; // covers all other cases } //-query the database table $sql=" SELECT ID, CSPC, Country, Producer, Wine, Year, Price FROM winecellar WHERE (CSPC LIKE '%" . $cob . "%' OR Country LIKE '%" . $cob ."%' OR Producer LIKE '%" . $cob ."%' OR Wine LIKE '%" . $cob ."%' OR Year LIKE '%" . $cob ."%') " . $pricerange; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $CSPC=$row['CSPC']; $Country=$row['Country']; $Producer=$row['Producer']; $Wine=$row['Wine']; $Year=$row['Year']; $Price=$row['Price']; $ID=$row['ID']; //-display the result of the array echo "&lt;ul&gt;\n"; echo "&lt;li&gt;" . $CSPC . "&lt;/li&gt;\n"; echo "&lt;li&gt;" . $Country . "&lt;/li&gt;\n"; echo "&lt;li&gt;" . $Producer . "&lt;/li&gt;\n"; echo "&lt;li&gt;" . $Wine . "&lt;/li&gt;\n"; echo "&lt;li&gt;" . $Year . "&lt;/li&gt;\n"; echo "&lt;li&gt;" . "&lt;a href=" . $Price . "&gt;" . "$" . $Price . "&lt;/a&gt;&lt;/li&gt;\n"; echo "&lt;/ul&gt;"; } } else{ echo "&lt;p&gt;Please enter a search query&lt;/p&gt;"; } } } ?&gt; </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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