need help in embbeding html into php

Discussion in 'PHP' started by cri8bat, Aug 4, 2009.

  1. #1
    Hi all,

    I have a table like this

    <?php do { ?>
    <td><?php echo $row_student_details['student_ref']; ?></td>
    <td><?php echo $row_student_details['student_name']; ?></td>
    <td><?php echo $row_student_details['course_name']; ?></td>
    <td><?php echo $row_student_details['start_date']; ?></td>
    <td><?php echo $row_student_details['end_date']; ?></td>
    <?php } while ($row_student_details = mysql_fetch_assoc($student_details)); ?>

    this is ok, but the problem is that it doesent display that way I wan, you see in the picture I enclosed, I want each recordset values to be puted below each other like this

    record1
    record2
    record3

    not
    record1 record2 record3

    can some pls. help me
     

    Attached Files:

    cri8bat, Aug 4, 2009 IP
  2. qazu

    qazu Well-Known Member

    Messages:
    1,834
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #2
    <td> is a cell <tr> is a row so you need to wrap your <td>s in a <tr>. Try this:

    <?php do { ?>
    <tr><td><?php echo $row_student_details['student_ref']; ?></td>
    <td><?php echo $row_student_details['student_name']; ?></td>
    <td><?php echo $row_student_details['course_name']; ?></td>
    <td><?php echo $row_student_details['start_date']; ?></td>
    <td><?php echo $row_student_details['end_date']; ?></td></tr>
    <?php } while ($row_student_details = mysql_fetch_assoc($student_details)); ?>
     
    qazu, Aug 4, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    <?php do { ?>
    <tr>
    <td><?php echo $row_student_details['student_ref']; ?></td>
    <td><?php echo $row_student_details['student_name']; ?></td>
    <td><?php echo $row_student_details['course_name']; ?></td>
    <td><?php echo $row_student_details['start_date']; ?></td>
    <td><?php echo $row_student_details['end_date']; ?></td>
    </tr>
    <?php } while ($row_student_details = mysql_fetch_assoc($student_details)); ?>
    PHP:
    Put your <tr> inside the loop instead of outside.
     
    premiumscripts, Aug 4, 2009 IP
  4. cri8bat

    cri8bat Well-Known Member

    Messages:
    1,459
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    160
    #4
    it workes!

    thank you!
     
    cri8bat, Aug 4, 2009 IP