Pretty much title. I'm new to html and just wanted to know how I'd be able to filter out columns on a database table. Here's what I got:
<?php
$link=@mysql_connect('localhost','root','');
mysql_select_db("home_work");
$sql="SELECT * FROM employee ";
$aResult=mysql_query($sql);
?>
<html>
<body bgcolor="Orange">
<H1>
<center>
<?php
echo '<p>Testing SQL table</p>' ;
?></p>
</center>
</H1>
<form action="columnChecks.php">
<input type="checkbox" name="columna" value="a1"> Column 1<br>
<input type="checkbox" name="columna" value="a2" > Column 2<br>
<input type="submit" value="Submit">
</form>
<form name="frmForm" id="frmForm" >
<table border="1" width="30%" height="30%">
<tr>
<th><font color='Purple'>ID</font></th>
<th><font color='Purple'>NAME</font></th>
<th><font color='Purple'>ADDRESS</font></th>
<th><font color='Purple'>DESIGNATION</font></th>
<th><font color='Purple'>SALARY</font></th>
</tr>
<?php
while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
{
$id = $rows['id'];
$empid = $rows['empid'];
$empname = $rows['empname'];
$empaddress = $rows['empaddress'];
$designation = $rows['designation'];
$salary = $rows['salary'];
?>
<tr>
<td><b><font color='#663300'><?php echo $empid;?></font></b></td>
<td><b><font color='#663300'><?php echo $empname;?></font></b></td>
<td><b><font color='#663300'><?php echo $empaddress;?></font></b></td>
<td><b><font color='#663300'><?php echo $designation;?></font></b></td>
<td><b><font color='#663300'><?php echo $salary;?></font></b></td>
</td>
</tr>
<?php } ?>
</table>
</form>
</body>
</html>
So I'm trying to make it so that the user will check whatever columns he/she wants displayed, and then a table will be made with only those columns.
First question: instead of using "Column 1" and "Column 2", is there a way I can pull out the name of the column itself and then insert the respective column's names in the place of "Column 1" and "Column 2"?
Whenever I just click on any of the buttons, it gives me a blank page (probably because I have nothing on the columnChecks.php document. How exactly do I handle the output from the submit form? I know the action attribute is columnChecks.php and that is where stuff goes down, the thing is I just don't know where to start that..