I've got a db_table where some cells contain comma separated arrays to link them to all the corresponding rows in a different table column, like [846,1400,1657].
So how do i select all rows where that cell has one matching value in the array?
$result = "";
$searchid = $_POST['id'];
$query = mysql_query("SELECT * FROM Company WHERE City/*<-the array*/ LIKE '%$searchid%'");
$count = mysql_num_rows($query);
if($count == 0){
$result .= "no companies";
} else {
while($row = mysql_fetch_array($query)){
$name = $row['Name'];
$result .= "<div class=\"result\">$name </div>";
}
}
echo $result;
This gives all companies with $searchid, but if $searchid = 25, it will return the ones with 25 in that column as well as those with for example 250 and 725. :/
Without the wildcards tho:
$query = mysql_query("SELECT * FROM Company WHERE City/*<-the array*/ = '$searchid'");
will return the rows with only $searchid in that cell, for example if $searchid = 25 a cell with [25] and not one with [25,456] or [12,13,25]
I've goggled for 48 hours and tried everything i found, think this should be an easy one to crack. What have i missed???