Check out the code ...

Reply

Join Date: Mar 2009
Posts: 14
Reputation: madristaa is an unknown quantity at this point 
Solved Threads: 0
madristaa madristaa is offline Offline
Newbie Poster

Check out the code ...

 
0
  #1
Mar 9th, 2009
Hello friends,

I am displaying the comments suggested by 4 faculty members for each student. I want displaying three columns. Let me start with the second column first, which displays
the Faculty 1, faculty 2, faculty 3, faculty 4. The third row display respectively comments given by faculty. Ok. Now the first column should display 1,2,3,4...n.
Where n is the total no. of row in proposal table.

IN proposal table i have columns
-student_id
-first_name
-last_name

In grade table i have columns
-student_id
-faculty_id
-comments

For example if there are 3 rows in proposal table than output should be like

1 | faculty 1 | comments by faculty 1
| faculty 2 | comments by faculty 2
| faculty 3 | comments by faculty 3
| faculty 4 | comments by faculty 4
2 | faculty 1 | comments by faculty 1
| faculty 2 | comments by faculty 2
| faculty 3 | comments by faculty 3
| faculty 4 | comments by faculty 4
3 | faculty 1 | comments by faculty 1
| faculty 2 | comments by faculty 2
| faculty 3 | comments by faculty 3
| faculty 4 | comments by faculty 4

RIGHT NOW EVERYTHING IS SHOWING PROPERLY EXCEPT THE FIRST COLUMN. CAN YOU PLZ HELP ME OUT? I AM ATTACHING MY CODE
  1. <h4><u>Comments</h3><br><br>
  2. <?
  3. $sql = "select * from proposal order by student_id";
  4. $result = mysql_query($sql);
  5. $num1=mysql_numrows($result);
  6.  
  7. while($rows=mysql_fetch_array($result))
  8. {
  9.  
  10. ?>
  11. <table>
  12. <tr>
  13.  
  14. <td>1</td>
  15.  
  16. <td><b><font size='2' face='Verdana'>Faculty 1</b></td>
  17. <td><b></td>
  18.  
  19. <?
  20.  
  21. $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='20'";
  22. $re = mysql_query($s1);
  23. $num=mysql_numrows($re);
  24. $i=0;
  25. while ($i < $num)
  26. {
  27. $comments=mysql_result($re,$i,"comments");
  28.  
  29. ++$i;
  30.  
  31. }
  32. if ($comments == '')
  33. {
  34. echo "<td >--</td>";
  35. }
  36. else
  37. {
  38. echo "<td ><font size='2' face='Verdana'>$comments</td>";
  39. }?></tr>
  40. <tr>
  41. <td></td>
  42. <td><b><font size='2' face='Verdana'>Faculty 2</td>
  43. <td><b></td>
  44.  
  45. <?
  46.  
  47. $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='25'";
  48. $re = mysql_query($s1);
  49. $num=mysql_numrows($re);
  50. $i=0;
  51. while ($i < $num)
  52. {
  53. $comments=mysql_result($re,$i,"comments");
  54.  
  55. ++$i;
  56.  
  57. }
  58. if ($comments == '')
  59. {
  60. echo "<td>--</td>";
  61. }
  62. else
  63. {
  64. echo "<td><font size='2' face='Verdana'>$comments</td>";
  65. }?>
  66. </tr><td></td>
  67. <td><b><font size='2' face='Verdana'>Faculty 3</td>
  68. <td><b></td>
  69. <?
  70.  
  71. $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='22'";
  72. $re = mysql_query($s1);
  73. $num=mysql_numrows($re);
  74. $i=0;
  75. while ($i < $num)
  76. {
  77. $comments=mysql_result($re,$i,"comments");
  78.  
  79. ++$i;
  80.  
  81. }
  82. if ($comments == '')
  83. {
  84. echo "<td >--</td>";
  85. }
  86. else
  87. {
  88. echo "<td ><font size='2' face='Verdana'>$comments</td>";
  89. }
  90. ?></tr><td>4</td>
  91. <td><b><font size='2' face='Verdana'>Faculty 4</td>
  92. <td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  93.  
  94. <?
  95.  
  96. $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='1'";
  97. $re = mysql_query($s1);
  98. $num=mysql_numrows($re);
  99. $i=0;
  100. while ($i < $num)
  101. {
  102. $comments=mysql_result($re,$i,"comments");
  103.  
  104. ++$i;
  105.  
  106. }
  107. if ($comments == '')
  108. {
  109. echo "<td>--</td>";
  110. }
  111. else
  112. {
  113. echo "<td><font size='2' face='Verdana'>$comments</td>";
  114. }?>
  115. </tr>
  116.  
  117. </table><?}?>
Last edited by madristaa; Mar 9th, 2009 at 1:21 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 830
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 136
Sponsor
pritaeas's Avatar
pritaeas pritaeas is online now Online
Practically a Posting Shark

Re: Check out the code ...

 
0
  #2
Mar 9th, 2009
Each comment line should be in it's own <tr>. You now have all comments inside one <td>. That won't work. I'll see if I can post code later.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 830
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 136
Sponsor
pritaeas's Avatar
pritaeas pritaeas is online now Online
Practically a Posting Shark

Re: Check out the code ...

 
0
  #3
Mar 9th, 2009
My guess is it should look something like this:

  1. <h4>Comments</h4>
  2. <table>
  3. <?php
  4. $sql = "select * from proposal order by student_id";
  5. $result = mysql_query($sql);
  6.  
  7. $faculties = array (20 => 'Faculty 1', 25 => 'Faculty 2', 22 => 'Faculty 3', 1 => 'Faculty 4');
  8. $number = 1;
  9.  
  10. while ($rows = mysql_fetch_array($result))
  11. {
  12. foreach ($faculties as $id => $name)
  13. {
  14. echo "<tr><th>$number</th><th>$name</th><td>";
  15. $s1 = "select comments from grade where student_id='" . $rows['student_id'] . "' and faculty_id='$id'";
  16. $re = mysql_query($s1);
  17. while ($rw = mysql_fetch_array($re))
  18. {
  19. if (empty($rw['comments']))
  20. {
  21. echo "--";
  22. }
  23. else
  24. {
  25. echo $rw['comments'];
  26. }
  27. echo '<br/>';
  28. }
  29. echo '</td></tr>';
  30. mysql_free_result($re);
  31. }
  32. $number++;
  33. }
  34. mysql_free_result($result);
  35. ?>
  36. </table>
Last edited by pritaeas; Mar 9th, 2009 at 8:05 am.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 14
Reputation: madristaa is an unknown quantity at this point 
Solved Threads: 0
madristaa madristaa is offline Offline
Newbie Poster

Re: Check out the code ...

 
0
  #4
Mar 9th, 2009
Thanks a lot man....your code help me out.....

I have one more column named comments, which shows the no.of rows starting from 1.

For example, if table 1 has 4 entries than output of comments columns will be like

1
2
3
4

But i want to dispaly the odd number row of red color and even row has blue color....

I can paste the code if you want to make some changes in it.

Can you still help me out?

Thanks
Last edited by madristaa; Mar 9th, 2009 at 3:04 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 830
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 136
Sponsor
pritaeas's Avatar
pritaeas pritaeas is online now Online
Practically a Posting Shark

Re: Check out the code ...

 
0
  #5
Mar 9th, 2009
Yes. Paste the code in a new thread, since it is a new question.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 14
Reputation: madristaa is an unknown quantity at this point 
Solved Threads: 0
madristaa madristaa is offline Offline
Newbie Poster

Re: Check out the code ...

 
0
  #6
Mar 9th, 2009
Ok. I will paste the code in the new thread. But do reply in it. As i think you will be able to solve it.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 14
Reputation: madristaa is an unknown quantity at this point 
Solved Threads: 0
madristaa madristaa is offline Offline
Newbie Poster

Re: Check out the code ...

 
0
  #7
Mar 9th, 2009
Hey dude I have created a new thread

The link for that thread is

http://www.daniweb.com/forums/post821767.html
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC