| | |
Check out the code ...
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2009
Posts: 14
Reputation:
Solved Threads: 0
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
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
PHP Syntax (Toggle Plain Text)
<h4><u>Comments</h3><br><br> <? $sql = "select * from proposal order by student_id"; $result = mysql_query($sql); $num1=mysql_numrows($result); while($rows=mysql_fetch_array($result)) { ?> <table> <tr> <td>1</td> <td><b><font size='2' face='Verdana'>Faculty 1</b></td> <td><b></td> <? $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='20'"; $re = mysql_query($s1); $num=mysql_numrows($re); $i=0; while ($i < $num) { $comments=mysql_result($re,$i,"comments"); ++$i; } if ($comments == '') { echo "<td >--</td>"; } else { echo "<td ><font size='2' face='Verdana'>$comments</td>"; }?></tr> <tr> <td></td> <td><b><font size='2' face='Verdana'>Faculty 2</td> <td><b></td> <? $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='25'"; $re = mysql_query($s1); $num=mysql_numrows($re); $i=0; while ($i < $num) { $comments=mysql_result($re,$i,"comments"); ++$i; } if ($comments == '') { echo "<td>--</td>"; } else { echo "<td><font size='2' face='Verdana'>$comments</td>"; }?> </tr><td></td> <td><b><font size='2' face='Verdana'>Faculty 3</td> <td><b></td> <? $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='22'"; $re = mysql_query($s1); $num=mysql_numrows($re); $i=0; while ($i < $num) { $comments=mysql_result($re,$i,"comments"); ++$i; } if ($comments == '') { echo "<td >--</td>"; } else { echo "<td ><font size='2' face='Verdana'>$comments</td>"; } ?></tr><td>4</td> <td><b><font size='2' face='Verdana'>Faculty 4</td> <td><b> </td> <? $s1="select comments from grade where student_id='".$rows['student_id']."' and faculty_id='1'"; $re = mysql_query($s1); $num=mysql_numrows($re); $i=0; while ($i < $num) { $comments=mysql_result($re,$i,"comments"); ++$i; } if ($comments == '') { echo "<td>--</td>"; } else { echo "<td><font size='2' face='Verdana'>$comments</td>"; }?> </tr> </table><?}?>
Last edited by madristaa; Mar 9th, 2009 at 1:21 am.
My guess is it should look something like this:
php Syntax (Toggle Plain Text)
<h4>Comments</h4> <table> <?php $sql = "select * from proposal order by student_id"; $result = mysql_query($sql); $faculties = array (20 => 'Faculty 1', 25 => 'Faculty 2', 22 => 'Faculty 3', 1 => 'Faculty 4'); $number = 1; while ($rows = mysql_fetch_array($result)) { foreach ($faculties as $id => $name) { echo "<tr><th>$number</th><th>$name</th><td>"; $s1 = "select comments from grade where student_id='" . $rows['student_id'] . "' and faculty_id='$id'"; $re = mysql_query($s1); while ($rw = mysql_fetch_array($re)) { if (empty($rw['comments'])) { echo "--"; } else { echo $rw['comments']; } echo '<br/>'; } echo '</td></tr>'; mysql_free_result($re); } $number++; } mysql_free_result($result); ?> </table>
Last edited by pritaeas; Mar 9th, 2009 at 8:05 am.
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Mar 2009
Posts: 14
Reputation:
Solved Threads: 0
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
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.
•
•
Join Date: Mar 2009
Posts: 14
Reputation:
Solved Threads: 0
Hey dude I have created a new thread
The link for that thread is
http://www.daniweb.com/forums/post821767.html
The link for that thread is
http://www.daniweb.com/forums/post821767.html
![]() |
Similar Threads
- huffman code (C++)
- help me (C)
- CALENDAR in TASM!!(pls check my code!!:) (Assembly)
- could you check my code ? (C)
- Again please someone check my code (C++)
- Check the code!! (C++)
- Would like for someone to check this to see if works and any help if it does not (Java)
- DrawHouse code help... (Java)
- DrawHouse Code Problem (Java)
Other Threads in the PHP Forum
- Previous Thread: Image Format Detection
- Next Thread: embedding java script in php
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





