这是我的代码。我希望通过从一个数据库中获取名称和家庭服务提供者和客户,首先获取名称和家庭service_provider,然后获取姓名和家庭客户。
<?php
$id=$fgmembersite->UserID();
/* echo "$id"; */
$db_host = 'localhost';
$db_name= 'site';
$db_table= 'action';
$db_user = 'root';
$db_pass = '';
$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");
$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
mysql_query("SET CHARACTER SET utf8");
$dbresult=mysql_query("SELECT tablesite.name as service_name,
tablesite.family as service_family,
tablesite.username,
tablesite.phone_number,
tablesite.email,
action.service_provider_comment,
action.customer_comment,
action.price,
action.date,
job_list.job_name,
action.ind
FROM $db_table
INNER JOIN job_list
on job_list.job_id=action.job_id
INNER JOIN tablesite
on tablesite.id_user=action.service_provider_id
WHERE vote!=''
UNION
SELECT tablesite.name as customer_name,
tablesite.family as customer_family
FROM $db_table
INNER JOIN job_list
on job_list.job_id=action.job_id
INNER JOIN tablesite
on tablesite.id_user=action.customer_id
WHERE vote!=''",$con);
$i = 1;
while($amch=mysql_fetch_assoc($dbresult))
{?>
<?php
echo "<form id='form_$i' method='post' action='{$_SERVER['PHP_SELF']}' accept-charset='UTF-8'>\r\n";
echo'<div dir="rtl">';
echo "نام خدمت دهنده: "."   ".$amch["service_name"]." ".$amch["service_family"]."   "."شماره تماس: ".$amch["phone_number"]."   "."ایمیل: ".$amch["email"].'<br>'.
"شغل انجام شده: ".$amch["job_name"].'<br>'
."تاریخ انجام عملیات: ".$amch["date"].'<br>'
."هزینه ی کار: ".$amch["price"]." تومان".'<br>'
."توضیحات خدمت دهنده".'<br>'."- ".$amch["service_provider_comment"].'<br>';
echo "نام خدمت گیرنده: ".$amch["customer_name"].$amch["customer_family"];
echo "پاسخ خدمت گیرنده".'<br>'."- ".$amch["customer_comment"].'<hr/>';
}
?>
</fieldset>
运行此代码后我遇到了这个问题:
(!)警告:mysql_fetch_assoc()要求参数1为资源,在第250行的C:\ wamp \ www \ source \ JobList.php中给出布尔值
表格动作:
包含服务提供商信息的表操作的一部分
SELECT tablesite.name as 'service_name',
tablesite.family as 'service_family',
tablesite.username,
tablesite.phone_number,
tablesite.email,
action.service_provider_comment,
action.customer_comment,
action.price,
action.date,
job_list.job_name,
action.ind
FROM $db_table
INNER JOIN job_list
on job_list.job_id=action.job_id
INNER JOIN tablesite
on tablesite.id_user=action.service_provider_id
WHERE vote!=''
包含客户信息的表操作的一部分:
SELECT tablesite.name as 'customer_name',
tablesite.family as 'customer_family'
FROM action
INNER JOIN job_list
on job_list.job_id=action.job_id
INNER JOIN tablesite
on tablesite.id_user=action.customer_id
WHERE vote!=''