I want to search in a database with variable positions. The variables are created here:
&numbers //= user input
&naar // = user input
$number = range($numbers+1, $naar -1); //define the range between the inputs
foreach ($number as $key=>$val){
$number[$key] = $letter.$val;} //define the array
$string = implode (' ',$number); // make a string from the array
This works fine. The output is a string that contains a minimum of 0 outputs and a maximun of 7 outputs. For example: A2 A3 A4 A5
I want the database to search if something is at one of the generated positions. Ive got this already:
$query="select chess_id from stelling where positie=\"".$number."\"";
$result = mysql_query($query, $connection);
$spring = 0;
if(mysql_num_rows($result)>0)
{
$spring = mysql_result($result, 0);
}
echo "$spring";
With this code only the last generated $string output will be checked. How can i let the database check all generated string code? For example:
$string = `A2 A3 A4 A5`
$query="select chess_id from stelling where positie=\"".$number."\"";
will only check A5
sample rows from table:
wt,A1 wp,A2 wl,A3 wq,A4
WHERE position IN ("A2", "A3", ...)
. – Barmar Jul 2 '13 at 8:23WHERE position BETWEEN "A2" AND "A5"
. – Barmar Jul 2 '13 at 8:23positie = "A2 A3 A4 A5"
compares the entire string to the column value, it doesn't look for partial matches? This is beginner stuff. – Barmar Jul 2 '13 at 8:34