0

Hello DaniWeb. I want to generate dynamic table for my cources table. I have tried this code but the header(semester) seems not to be working.

<section class="entry-content">
                        <?php 
                       $counter=1;
                        $slect="Select * from mcs";
                        $qry=  mysql_query($slect);
                        while($row=mysql_fetch_row($qry))
                        {
                            if($counter==$row[1])
                                {
                                print "<div class='heading vcMsg'>
                                                 <h3>SEMESTER  $row[1] </h3>
                        </div>

                               <div class='column message-column'>
                            <p>
                            <table class='course-profile'>
                                <tbody>
                                     <tr>

                                        <th>title</th>
                                        <th>cource</th>
                                        <th>Credits</th>
                                        <th>Marks</th>
                                    </tr>
                                    ";
                                $counter++;
                                }
                                print " <tr>

                                        <td>$row[2]</td>
                                        <td>$row[3]</td>
                                        <td>$row[4]</td>
                                        <td>$row[5]</td>
                                    </tr>";              


                                }
                                   print " </tbody>  </table>
                            </p>
                            <div class='clear'></div>
                            </div>";

                         ?>

bad0e334c86ec3905b70db2895b0e329

above is the output of this code.. Help...!

Edited by thirsty.soul: PHP

2
Contributors
4
Replies
22
Views
3 Years
Discussion Span
Last Post by thirsty.soul
0
  <section class="entry-content">
                    <div class='heading vcMsg'>
                                             <h3>SEMESTER  1 </h3>
                    </div>


                        <div class='column message-column'>
                        <p>
                        <table class='course-profile'>
                            <tbody>
                                 <tr>

                                    <th>title</th>
                                    <th>cource</th>
                                    <th>Credits</th>
                                    <th>Marks</th>
                                </tr>
                                 <tr>

                                    <td>MCS-131</td>
                                    <td>Digital Logic & Design</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr> <tr>

                                    <td>MCS-142</td>
                                    <td>Intro to OOP</td>
                                    <td>3</td>
                                    <td>150</td>
                                </tr> <tr>

                                    <td>MCS-133</td>
                                    <td>Data Structure</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr> <tr>

                                    <td>MCS-134</td>
                                    <td>D.S</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr> <tr>

                                    <td>MCS-135</td>
                                    <td>Func: English</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr><div class='heading vcMsg'>
                                             <h3>SEMESTER  2 </h3>
                    </div>


                        <div class='column message-column'>
                        <p>
                        <table class='course-profile'>
                            <tbody>
                                 <tr>

                                    <th>title</th>
                                    <th>cource</th>
                                    <th>Credits</th>
                                    <th>Marks</th>
                                </tr>
                                 <tr>

                                    <td>MCS-231</td>
                                    <td>DBS</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr> <tr>

                                    <td>MCS-232</td>
                                    <td>Automata Theory</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr> <tr>

                                    <td>MCS-233</td>
                                    <td>D & Analaysis of Alogo:</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr> <tr>

                                    <td>MCS-233</td>
                                    <td>O.S</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr> <tr>

                                    <td>MCS-244</td>
                                    <td>Advanced OOP</td>
                                    <td>3</td>
                                    <td>150</td>
                                </tr> <tr>

                                    <td>MCS-235</td>
                                    <td>Intro Signal Proc:</td>
                                    <td>3</td>
                                    <td>100</td>
                                </tr><div class='heading vcMsg'>
                                             <h3>SEMESTER  3 </h3>
                    </div>


                        <div class='column message-column'>
                        <p>
                        <table class='course-profile'>
                            <tbody>
                                 <tr>

                                    <th>title</th>
                                    <th>cource</th>
                                    <th>Credits</th>
                                    <th>Marks</th>
                                </tr>
                                 <tr>

                                    <td>MCS-341</td>
                                    <td>MP & AL</td>
                                    <td>4</td>
                                    <td>150</td>
                                </tr> </tbody>  </table>
                        </p>
                        <div class='clear'></div>
                        </div>    
                             <div class="heading vcMsg">
                        <h3>Contacts</h3>
                    </div>
                    <div class="column message-column">
                        <p>
                            <b>Office</b>: 0966-750266, 0966-750279<br>
                            <b>Exchange</b>: 0966-750424-9 Ext: 101<br>
                            <b>Fax</b>: 0966-750255
                        </p>
                    </div>
                    <div class="clear"></div>
                </section>
1
<div class='column message-column'>

That one is not closed before the new semester. Nor is the table and the p tag.

Edited by pritaeas

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.