0

I want to create dynamic table with mysql data I want to create table as mentioned in 'demo1' but I have problem with with table format as shown in 'demo' . query and values are correct but I want to get corret table format.

demo 1 enter image description here

demo enter image description here

  <table class=demo border=1>
    <tr style='height:10px'>
    <td style='align:center;width:30px'class="client">Clientname</td>
<td style='align:center'class="req">Requirement</td>


<td style='align:center;width:30px' class="resume">Resume</td>
<td style='align:center;width:30px' class="resume">Interview</td>
<td style='align:center;width:30px'class="status">Placed</td></tr>
  <tr>  
        <?php  
        include "config.php";
      //  echo '<table>';
       $sql="select * from client";    
        $sql1=mysql_query($sql);

        while($fet=mysql_fetch_assoc($sql1))  
        {
      //   echo '<tr>';
        $c_id=$fet['c_id'];
        $c_name=$fet['c_id'];

            echo '<td>'.$fet['c_name'].'</td>';
          echo '<td colspan=4>';
           $res="SELECT a.req_id,a.title,(select count(*) from resume as b where a.req_id=b.req_id) as submittal,(select count(b.interview) from resume as b where b.e_id='$ses' and b.interview!='0000-00-00' and a.req_id=b.req_id)as interview,(select count(*) from resume as b where placed=1 and a.req_id=b.req_id) as placed FROM `requirement` as a,resume as b  where a.c_id='$c_id' and a.e_id='$ses' group by a.req_id";
            $re=mysql_query($res);
            echo '<table border=1 >';   
            while($res1=mysql_fetch_assoc($re))
            {
            echo '<tr>';
            echo '<td>'.$res1["title"].'</td>';
            echo '<td>'.$res1["submittal"].'</td>';
            echo '<td>'.$res1["interview"].'</td>';
            echo '<td>'.$res1["placed"].'</td>';
            echo '</tr>';
            }
             echo '</table>';
             echo '</td>';
         echo '</tr>';
        }
      ?>
      </table>
0

2 Answers 2

1

you can use use this:

<table class=demo border=1>
  <tr style='height:10px'>
    <td style='align:center;width:30px'class="client">Clientname</td>
    <td style='align:center'class="req">Requirement</td>


    <td style='align:center;width:30px' class="resume">Resume</td>
    <td style='align:center;width:30px' class="resume">Interview</td>
    <td style='align:center;width:30px'class="status">Placed</td>
  </tr>
    <?php
    include "config.php";
    //  echo '<table>';
    $sql="select * from client";
    $sql1=mysql_query($sql);

    while($fet=mysql_fetch_assoc($sql1))
    {
        //first count your group rows
        $count = 5;//group rows

        //create gruop start
        $i = 1;
        while($i < $count){

            //group row start
            echo "<tr>";

            if($i = 1)
                echo "<td rowspan='$count'>your client</td>";

            echo '<td>title</td>';
            echo '<td>submittal</td>';
            echo '<td>interview</td>';
            echo '<td>placed</td>';

            //group row end
            echo "</tr>"
        }
    }
    ?>
</table>
Sign up to request clarification or add additional context in comments.

Comments

0

Remove colspan=4 and add rowspan with the number of the rows under the specific client.

http://www.w3schools.com/tags/att_td_rowspan.asp

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.