Hi All, I am making a daily activity report using php and mysql.Now while doing this I am facing some problems.Let me explain you.The below is the code where I am building a two dimensional array. $sql=mysql_query("select * from report,admin_table where report.admin_id=admin_table.admin_id and which_day='2010-2-2' ") or die(mysql_error()); while($row=mysql_fetch_array($sql)) { $admin_name=$row['admin_name']; $activity=$row['activity']; $test_array[] = array($admin_name,$activity,); } PHP: Now if I print this test array it gives as Array ( [0] => Array ( [0] => aziz [1] => dsdsds ) [1] => Array ( [0] => anis [1] => sdsdsdsdsd ) [2] => Array ( [0] => mujeeb [1] => sdsdsd ) [3] => Array ( [0] => raj [1] => dsdwew ) [4] => Array ( [0] => raj [1] => cdsfdfdfd ) ) Code (markup): while printing it as html table it displays as <table border="1"><tr><th>aziz</th><th>anis</th><th>mujeeb</th><th>raj</th><th>raj</th></tr><tr><td>dsdsds</td><td>sdsdsdsdsd</td><td>sdsdsd</td><td>dsdwew</td><td>cdsfdfdfd</td></tr></table> HTML: which is not a desired output.I like to display it as <table border="1"><tr><th>aziz</th><th>anis</th><th>mujeeb</th><th>raj</th></tr><tr><td>dsdsds</td><td>sdsdsdsdsd</td><td>sdsdsd</td><td>dsdwew</td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td>cdsfdfdfd</td> </tr> </table> HTML: Am i doing wrong in building up the array or doing wrong in displaying html.I guess its wrong in building up the array...I can't understand..Please suggest. Thanks, Raj
Your desired output seems very arbitrary. You want the first <tr> to appear on the same line as table, with a </tr> on a second line, and the last row to appear with each <td> on its own line with tabs indented? Just throw some newlines in there when you're outputting with "\n" and you'll be fine.