tippytarka
Programmer
i'm a little lost with how to print all the elements of an array into a table cell. i'm using a 'for loop' to loop all the elements.
this query gives me the result.... one, two, three, four, (which is want i want)
but when i place $col within the table cell (outside of the 'for loop') ...like in the following script, i get only a result of.... four, (and i want to avoid elements one, two, three, from being overwritten)
if i place the entire 'for loop' and query inside the echoed table cell i get an error message on the WHERE line in the query..
how on earth do i resolve this??
this query gives me the result.... one, two, three, four, (which is want i want)
Code:
for ($i = 0; $i < count($jobid); $i++) {
$query = "SELECT p1_job_title_code.job_title_01
FROM p1_job_title_code
WHERE p1_job_title_code.job_title_id = '".$jobid[$i]."'";
$query_result = mysql_query($query);
$column = mysql_fetch_row($query_result);
$col = ''.$column[0].', ';
echo $col;
}
but when i place $col within the table cell (outside of the 'for loop') ...like in the following script, i get only a result of.... four, (and i want to avoid elements one, two, three, from being overwritten)
Code:
echo '<tr>';
echo '<td>JOB TITLES</td>';
for ($i = 0; $i < count($jobid); $i++) {
$query = "SELECT p1_job_title_code.job_title_01
FROM p1_job_title_code
WHERE p1_job_title_code.job_title_id = '".$jobid[$i]."'";
$query_result = mysql_query($query);
$column = mysql_fetch_row($query_result);
$col = ''.$column[0].', ';
}
echo '<td>'.$col.'</td>';
echo '</tr>';
if i place the entire 'for loop' and query inside the echoed table cell i get an error message on the WHERE line in the query..
how on earth do i resolve this??