一件小事我需要你的帮助。我有两个表,我需要从第一个表中获取人员的姓名和 ID 列表。然后使用此列表获取与这些人相关的服务。请记住,我需要名称和 ID 来识别服务。
查询类似于以下内容:
$query = "SELECT id, name from person where customerType='specificType';
$result = mysql_query($query,$this->connection);
之后,我遍历此查询的结果以获取服务列表:
While ($list=mysql_fetch_array($result))
{
$query = "SELECT serviceID, serviceName from services
where assignedToName='".$list['name']."' and assignedToID=".$list['id'];
$result2 = mysql_query($query,$this->connection);
if(!$result2 || mysql_num_rows($result2) <= 0)
{//I do nothing}
else{
if(isset($servicesList))
{
//Here is the part that is not working, How to combine the results??
$servicesList .= $result;
}
else $servicesList=$result;
}
}
//End While
if(isset($servicesList))
{ return $servicesList;}else {
return 'error';
}
提前致谢...