<?php
/*
CREATE TABLE `test` (
  `a` varchar(10) NOT NULL default '',
  `b` varchar(10) NOT NULL default '',
  `c` varchar(10) NOT NULL default '',
  `d` varchar(10) NOT NULL default '',
  `e` varchar(10) NOT NULL default ''
) TYPE=MyISAM;
INSERT INTO `test` VALUES ('1', '2', '3', '4', '5');
INSERT INTO `test` VALUES ('6', '7', '8', '9', '0');
INSERT INTO `test` VALUES ('11', '12', '13', '14', '15');
INSERT INTO `test` VALUES ('16', '17', '18', '19', '20');
INSERT INTO `test` VALUES ('21', '22', '23', '24', '25');
INSERT INTO `test` VALUES ('26', '27', '28', '29', '30');
*/
$host='localhost';
$user='root';
$pswd='';
$dbname='test';
$conn=mysql_connect($host, $user, $pswd);
mysql_select_db($dbname, $conn);
echo '<form method="post">';
$sql="show fields from test";
$query=mysql_query($sql);
while($rs=mysql_fetch_array($query)){
echo '<input type="checkbox" name="field[]" value="'.$rs[Field].'"> '.$rs[Field].' ';
}
echo '<input type="submit" name="Submit">';
echo '</form>';
if($Submit){
echo '<table>';
echo '<tr align="center">';
is_array($field)?null:$field=array();
foreach ($field as $v) echo '<td><b>'.$v.'</b></td>';
echo '</tr>';
$sql="select * from test";
$query=mysql_query($sql);
while($rs=mysql_fetch_array($query)){
echo '<tr>';
foreach($field as $v) echo '<td>'.$rs[$v].'</td>';
echo '</tr>';
}
echo '</table>';
}
?>