i would like to print 'for loop' results into a table but i'm having some difficulty making the results appear in the correct columns and rows. this is my first attempt at printing a 'for loop' into a table and if its just one 'for loop' then i'm ok, but if its several 'for loops' to print in proceeding columns ...after many varied attempts i just can't get it right. i think its something to do with where i place my curly brackets but if someone could show me what I'm doing wrong i would be so grateful!
here is my code....
// define table
echo "<table width=\"555\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\">";
// 1st table header (TOTAL COUNT)
echo "<tr bgcolor=\"#FF943C\">";
echo "<td height=\"22\" colspan=\"5\" align=\"center\" class=\"style63\">TOTAL COUNTS</td>";
echo "</tr>";
// 2nd table header (JOB TITLE, WITH TEL, WITH EMAIL, TOTAL)
echo "<tr bgcolor=\"#FF943C\">";
echo "<td height=\"31\" colspan=\"2\" align=\"center\" class=\"style60 style4\">JOB TITLE</td>";
echo "<td width=\"92\" height=\"31\" align=\"center\" class=\"style60 style4\">WITH TEL</td>";
echo "<td width=\"92\" height=\"31\" align=\"center\" class=\"style60 style4\">WITH EMAIL</td>";
echo "<td width=\"92\" height=\"31\" align=\"center\" class=\"style60 style4\">TOTAL</td>";
// for loop and query (JOB TITLE)
for ($i = 0; $i < count($job_title_id); $i++) {
$sql_job_title_name = ("SELECT p1_job_title_code.job_title_01
FROM p1_job_title_code
WHERE p1_job_title_code.job_title_id = '".$job_title_id[$i]."'");
$result_job_title_name = mysql_query($sql_job_title_name);
$name_job_title_name = mysql_result($result_job_title_name,0,0);
// column 1 (JOB TITLE)
echo "<tr><td>";
echo $name_job_title_name;
echo "</td><td>";
}
// for loop and query (TOTAL)
for ($i = 0; $i < count($job_title_id); $i++) {
$sql_job_title_count = ("SELECT COUNT(*)
FROM p1_list_creative
WHERE p1_list_creative.country_id = '".$country_id."'
AND p1_list_creative.job_title_id = '".$job_title_id[$i]."'");
$result_job_title_count = mysql_query($sql_job_title_count);
$num_job_title_count = mysql_result($result_job_title_count,0,0);
} {
// column 2 (TOTAL)
echo $num_job_title_count;
}
echo "</td></tr>";
// end table
echo "</table>";
here what i'm trying to achieve....
TOTAL COUNTS
JOB TITLE TOTAL WITH EMAIL WITH TEL
Creative 2313
Designer 10370
Photographer 416
.....Creative Director, Designer, Photographer are the "$name_job_title_name" results that i would like to align in column "JOB TITLE"
.....2313, 10370, 416 are the "$num_job_title_count" results that i would like to align in the column "TOTAL"
Cheers!