Jump to content

Displaying HTML


thatsme2

Recommended Posts

Hello,

 

I have a table in database where the member details are stored.

member_id

first_name

last_name

test_name

score

 

 

I want to retrive the above values and display in the below format.

 

 

<table width="416" height="184" border="1">

  <tr>

    <td width="62" height="23">Members > </td>

    <td width="80">member1</td>

    <td width="80">member2</td>

    <td width="80">member3</td>

    <td width="80">member...n</td>

  </tr>

  <tr>

    <td height="23"><p>Tests </p>

    <p>V</p></td>

    <td> </td>

    <td> </td>

    <td> </td>

    <td> </td>

  </tr>

  <tr>

    <td height="23">test1</td>

    <td>m1_t1_score</td>

    <td>m2_t1_score</td>

    <td>m3_t1_score</td>

    <td>m1_t1_score</td>

  </tr>

  <tr>

    <td height="23">test2</td>

    <td>m1_t2_score</td>

    <td>m2_t2_score</td>

    <td>m3_t2_score</td>

    <td>m2_t2_score</td>

  </tr>

  <tr>

    <td height="23">test...n</td>

    <td>m1_tn_score</td>

    <td>m2_tn_score</td>

    <td>m3_tn_score</td>

    <td>mn_tn_score</td>

  </tr>

</table>

 

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/96823-displaying-html/
Share on other sites

this?

$result = mysql_query("SELECT * FROM memeber ");

while($row = mysql_fetch_array($result))
  {
  echo 
  '<tr>
    <td height="23"><p>'.$row['test_name'].'</p><p>V</p></td>
    <td>'.$row['member_id'].'</td>
    <td>'.$row['first_name'].'</td>
    <td>'.$row['last_name'].'</td>
    <td>'.$row['score'].'</td>
  </tr>';
  
    }

Link to comment
https://forums.phpfreaks.com/topic/96823-displaying-html/#findComment-495487
Share on other sites

Thanks.  The problem is i have to show the test_name also.  The structure is,

 

member_id

first_name

last_name

test_name

score

test_name

 

In the first row,

Members>    member1  member2  member3  member n

 

Members> is static text.  member1, member2...member..n are dynamic

 

In the second row,

Tests V            -                -                  -            -

 

Tests V is static text.     

 

In the third row,

 

test1          m1_t1_score    m2_t1_score    m3_t1_score  mn_t1_score

 

test1 is dynamic test name.  m1_t1_score, m2_t1_score....mn_t1_score  are scores of members in test1

 

in the fourth row,

test2          m1_t2_score    m2_t2_score    m3_t2_score  mn_t2_score

 

test2 is dynamic test name.  m1_t2_score, m2_t2_score ....mn_t2_score  are scores of members in test2

 

This pattern continues till test n.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/96823-displaying-html/#findComment-495505
Share on other sites

if you want to rewrite a table across first like that you need to first store the data

<?php
$fields = array("member_id", "first_name", "last_name", "test_name", "score");
$q = "select ".implode(" , ",$fields)." from `member` Order By member_id ASC";
$r= mysql_query($q) or die(mysql_error()."<br /><br />".$q);
$i = 0;
while($row = mysql_fetch_assoc($result)){
foreach($row as $key=> $value){
	$data[$i][$key] = $value;
}
$i++;  
}
echo "<table>";
foreach($fields as $value){
echo "<tr>";
$i = 0;
while($i < count($data)){
	echo "<td>".$data[$i][$value]."</td>";
	$i++;
}
echo "</tr>";
}
echo "</table>";
?>

 

Link to comment
https://forums.phpfreaks.com/topic/96823-displaying-html/#findComment-495509
Share on other sites

Thank you.

 

You almost got solved my problem. 

 

1.  member_id is not primary_key.

    memer_id will repeat as he attemps more than one test.

 

In the first row, all the members should be displayed

From the second row, all first column will have test names

second row - from second column to member_n column members score is displayed.

 

second row pattern repeats in third row, fourth row to  test_n row

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/96823-displaying-html/#findComment-495656
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.