I'm a bit of a beginner at sql but I believe this should work. I'm doing it step by step so this isn't the complete code yet but I've hit a problem. Basically what I'm trying to do is use the array created from the form:
<form action="search.php" method="post">
<input type="checkbox" name="features[]" value="Texture" >Textures<br />
<input type="checkbox" name="features[]" value="Items" >Items<br />
<input type="checkbox" name="features[]" value="GUI" >Gui<br />
</form
And create what will be end up being a query for my database. Here's the PHP code:
<?php
$button = $_POST['submit'];
$features = $_POST['features'];
if ($button){
//connect
mysql_connect("server","username","password");
mysql_select_db("rdm");
foreach ($features){
$x++;
if ($x=1)
$construct .= "feature LIKE '$features[$x]'";
else
$construct .= " OR feature LIKE '$features[$x]'";
}
$construct = "SELECT * FROM Textures WHERE '$construct';
echo $construct;
?>
My understanding is this should echo out the variable $construct, which will contain the text "SELECT * FROM Textures WHERE feature LIKE ... and then the first value in the features array, followed by the other values.
Any help as to why this isn't working would be fantastic! As I say, I'm pretty new to this so sorry if this is a silly mistake.
Thanks in advance!
foreach.if ($button){if ($x=1)instead of comparing values.