Problem with table in php

Posted by user225269 on Stack Overflow See other posts from Stack Overflow or by user225269
Published on 2010-04-28T08:45:03Z Indexed on 2010/04/28 8:53 UTC
Read the original article Hit count: 159

Filed under:
|

I'm trying to create a table in php that would show the data on the mysql database based on the check box that is checked by the user. As you can see in this screen shot, it will have problems when you did not check on a checkbox before the one that will be the last: http://www.mypicx.com/04282010/1/

Here is my code:

if($_POST['general'] == 'ADDRESS'){
$result2 = mysql_query("SELECT * FROM student WHERE ADDRESS='$saddress'");
 ?>



<table border='1'>
<tr>
<th>IDNO</th>
<th>YEAR</th>
<th>SECTION</th>

<?php if ( $ShowLastName )
echo "<th>LASTNAME</th>" ?>

<?php if ( $ShowFirstName  )
echo "<th>FIRSTNAME</th>" ?>


<?php if ( $ShowMidName  )
echo "<th>MIDNAME</th>" ?>


<?php if ( $ShowAddress  )
echo "<th>ADDRESS</th>" ?>


<?php if ( $ShowGender  )
echo "<th>GENDER</th>" ?>

<?php if ( $ShowReligion  )
echo "<th>RELIGION</th>" ?>

<?php if ( $ShowBday  )
echo "<th>BIRTHDAY</th>" ?>

<?php if ( $ShowContact  )
echo "<th>CONTACT</th>" ?>
</tr>


<?php
while($row = mysql_fetch_array($result2))
  {?>
    <tr> 
    <td><?php echo $row['IDNO']?> </td>
 <td><?php echo $row['YEAR'] ?> </td>
   <td><?php echo $row['SECTION'] ?></td>


  <td><?php
   if ( $ShowLastName  )
  echo $row['LASTNAME'] ?></td>

    <td><?php
   if ( $ShowFirstName  )
  echo $row['FIRSTNAME'] ?></td>

             <td><?php
   if ( $ShowMidName  )
  echo $row['MI'] ?></td>


   <td><?php
   if ( $ShowAddress  )
  echo $row['ADDRESS'] ?></td>

  <td><?php
   if ( $ShowGender  )
  echo $row['GENDER'] ?></td>



  <td><?php
   if ( $ShowReligion  )
  echo $row['RELIGION'] ?></td>

  <td><?php
   if ( $ShowBday  )
  echo $row['BIRTHDAY'] ?></td>

  <td><?php
   if ( $ShowContact  )
  echo $row['S_CONTACTNUM'] ?></td>



   </tr>

<?PHP   }  ?>
    </table>

<?PHP }






mysql_close($con);
?>

What can you recommend so that the output will not look like this when you one of the checkbox before a checkbox is not clicked: http://www.mypicx.com/04282010/2/ alt text

© Stack Overflow or respective owner

Related posts about php

Related posts about html