Hi,
I'm looking for some help please to write a function, which:
1) Queries a database
2) Could return ONE or MORE results
3) Return either the ONE or MORE results comma seperated
However, I can only get this to return one value, how would I get it to return multiple values?
So the above could return multiple ids eg:
1,56,86,72
Or simply just a single id eg:
56
Can this be done and can anyone kindly help please?
Thanks
I'm looking for some help please to write a function, which:
1) Queries a database
2) Could return ONE or MORE results
3) Return either the ONE or MORE results comma seperated
However, I can only get this to return one value, how would I get it to return multiple values?
PHP Code:
function findName($name) {
$sql = "select id from table WHERE name LIKE '%$name%'";
$query = mysql_query($sql);
while($result = mysql_fetch_array($query) {
$the_ids = $result['id'];
}
return $the_ids;
}
1,56,86,72
Or simply just a single id eg:
56
Can this be done and can anyone kindly help please?
Thanks
Comment