I have an string 1 set is ..
$str = RP-01,RP-11,RP-12,RP-20,RP-75,RP-92
and then I have change that sting into the Array to be like this for prepare to query MySQL by using the implode()
$final = (explode(",",$str));
Array ( [0] => RP-01 [1] => RP-11 [2] => RP-12 [3] => RP-20 [4] => RP-75 [5] => RP-92 )
$result = mysql_query("SELECT report.report_id, report_year, report_status, report_type, teacher_name, abstract, report_position, report_name,
GROUP_CONCAT(student_name ORDER BY student_name ASC SEPARATOR ', ') AS student_name
FROM student RIGHT JOIN report ON student.report_id = report.report_id
WHERE report.report_id IN (".implode(',', $final).") ");
The finally I was try to used implode() to query in the MySQL and last result is still
mysql_fetch_array() expects parameter 1 to be resource, boolean given in ....
in line : while($row = mysql_fetch_array($result)){ ..}
Why is always happened that.
Thanks all guys .
</div>
Add "
s -
report.report_id IN ('".implode("','", $final)."') ");
Strings must be quoted.
$result = mysql_query("SELECT report.report_id, report_year, report_status, report_type, teacher_name, abstract, report_position, report_name, GROUP_CONCAT(student_name ORDER BY student_name ASC SEPARATOR ', ') AS student_name FROM student RIGHT JOIN report ON student.report_id = report.report_id WHERE report.report_id IN (' ".implode(',', $final).") " ');