Hello All,
I have fetched array from database,
it is two dimentinal array.
and want to print it into html table.
But when print it's need attribute while printing it.
here is code:

<tr>
    <th>Sr.No.</th>
    <th>Skill type</th>
    <th>Skill Name</th>
    <th>Project</th>
    <th>Practice</th>
    <th>Description </th>
</tr>
<?
$skills_1=[HERE I HAVE FETCHED ARRAY FROM DATABASE];
?>
<table class='GoalsettingTable'>
    Skills used by employee:
<tr>
    <th>Sr.No.</th>
    <th>Skill type</th>
    <th>Skill Name</th>
    <th>Project</th>
    <th>Practice</th>
    <th>Description </th>
</tr>
<?
if(sizeof($skills_1)>0)
{
    $array_size=sizeof($skills_1);
    for ($index=0;$index < $array_size ;$index++)
    {
        echo "<tr>";     
        for ($inner_index=0;$inner_index < 6 ;$inner_index++)
        {
            echo $index;
            echo $skills_1[$index]['skill_id'];
            echo $skills_1[$index]['skill_id'];
            echo $skills_1[$index]['practice'];
            echo $skills_1[$index]['project'];
        }
        echo "</tr>"; */
    }

}
?>
</table>

But its print incorrect.
it is printing each array in each <td>

I want to print inner loop like echo "<td>".$skills_1[$index][$inner_index]."</td>";
but it is not printing because of attribute.

how can i print this?

It would be helpful if we see the actual data in the array. Put this code between lines 10 and 11:

die(print_r($skills_1, 1));

Post the output here.

It is also (usually) easier to use a foreach loop to process an array instead of all the for stuff.

Try...

if(count($skills_1))
{
    foreach($skills_1 as $i=>$skills)
    {
        echo '<tr>';
        foreach($skills as $key=>$skilldata)
            echo '<td>'.$skilldata.'</td>';
        echo '</tr>';
    }
}

Hope it helps!

commented: nice bro. +10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.