Note that there are some explanatory texts on larger screens.

plurals
  1. PO'search database using multiple checkboxes'
    primarykey
    data
    text
    <p>I have a page with multiple check boxes on, each box correspond to each ingredient (fig.1)</p> <p>Database is called 'Recipes'</p> <p>(fig.1)<br> Table name = 'ingredients'</p> <ul> <li>ID ingredient</li> <li>1 olive oil </li> <li>2 black pepper</li> <li>3 beef stock</li> </ul> <p>and so on......</p> <p>this table is the main one and as the site grows so will the number of ingredients and check boxes to match.</p> <p>I also have several more tables, each being a recipe (fig.2)</p> <p>(fig.2)<br> Table name = 'Lasagne'</p> <p>ingredient_id</p> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul> <p>and so on......</p> <p>for each recipe the ingredient_id matches one of the ID's in the the main table (fig.1).</p> <hr> <p>I want to have it so that someone can select as many check boxes as they want. When they click on submit, it brings back each recipe starting with the closest matched to the ingredients followed by a-z at the top.........I know when you type echo that it prints what you say on the screen...If I had a table in place on the search.php page, could each recipe result be echo'd into each row in the table in in order as mentioned above?</p> <p>This is what I have so far....</p> <p>index.html..</p> <pre><code>&lt;form action="search.php" method="post" name="search_form" onsubmit="return checked boxes" &gt; &lt;table width="571" border="0"&gt; &lt;tr&gt; &lt;td width="183" valign="top"&gt;&lt;input type="checkbox" name="search[]" value="Olive oil" id="1"/&gt; Olive oil&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="black pepper" id="2"/&gt; Black pepper&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="beef stock" id="3"/&gt; Beef stock&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="lean steak mince" id="4"/&gt; Lean steak mince&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="mushrooms" id="5"/&gt; Mushrooms&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="red onion" id="6"/&gt; Red onion&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="garlic" id="7"/&gt; Garlic&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="tomato concentrate" id="8"/&gt; Tomato concentrate&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="lasagna sheets" id="9"/&gt; Lasagna sheets&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="milk" id="10"/&gt; Milk&lt;br/&gt;&lt;/td&gt; &lt;td width="171" valign="top"&gt;&lt;input type="checkbox" name="search[]" value="cheese" id="11"/&gt; Cheese&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="butter" id="12"/&gt; Butter&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="plain flour" id="13"/&gt; Plain flour&lt;br/&gt; &lt;input type="checkbox" name="search[]" value="chopped tomatos" id="14"/&gt; Chopped tomato&lt;br/&gt;&lt;/td&gt; &lt;td width="195"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="submit" value="search"/&gt; &lt;/form&gt;' </code></pre> <p>search.php</p> <pre><code>$username = "root"; $password = ""; $hostname = "localhost"; $dbhandle = mysql_connect("localhost", "root","" ) or die("Unable to connect to MySQL"); $selected = mysql_select_db("recipes",$dbhandle) or die("Could not select recipes");' </code></pre>
    singulars
    1. This table or related slice is empty.
    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