getting results from a dynamic comma delimited list
Posted: Thu May 26, 2005 12:51 pm
I get a comma delimited list (i.e. "1,3,4") in "services" stored in a string from the following query:
$query = "SELECT services FROM businesses WHERE id = '".mysql_escape_string($_GET['id'])."'";
$result = mysql_query($query);
$business = mysql_fetch_array($result);
mysql_free_result($result);
Now from this result, I would like to pick up all the service names from a different table where the id is an integer
$query = "SELECT name AS servicename FROM service WHERE id IN (".mysql_escape_string($business[ 'servicenames' ]).")";
$result = mysql_query($query);
$services = mysql_fetch_array($result);
mysql_free_result($result);
This is not working in mysql
. Can anybody help?
Thanks,
Anthony
$query = "SELECT services FROM businesses WHERE id = '".mysql_escape_string($_GET['id'])."'";
$result = mysql_query($query);
$business = mysql_fetch_array($result);
mysql_free_result($result);
Now from this result, I would like to pick up all the service names from a different table where the id is an integer
$query = "SELECT name AS servicename FROM service WHERE id IN (".mysql_escape_string($business[ 'servicenames' ]).")";
$result = mysql_query($query);
$services = mysql_fetch_array($result);
mysql_free_result($result);
This is not working in mysql
Thanks,
Anthony