473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

While row displaying repeated values

I need help..i have a while loop inside a while loop..
and it displays repeated values.can anyone help me..thanks in advance...
Expand|Select|Wrap|Line Numbers
  1. if ($_REQUEST['sem']==2){
  2.             $result="select g.* from grades as g, prospectus as p where g.idno='".$_REQUEST['idno']."' and g.course='".$_REQUEST['course']."' and g.year='".$_REQUEST['year']."' and g.sem=1 and g.syear='".$_REQUEST['syear']."' and g.remarks='failed' and g.subid=p.prerequisite1";
  3.             $rsq=mysql_query($result);
  4.             if(mysql_num_rows($rsq)>=1){//if student exist in first sem..evaluate grades for second sem
  5.             while($grade=mysql_fetch_array($rsq)){
  6.                 $grades=$grade['subid'];
  7.                 //echo "".$grades."<br />";
  8. $race = mysql_query("SELECT DISTINCT subid FROM prospectus
  9. WHERE prospectus.prerequisite1
  10. NOT IN (
  11. SELECT prospectus.subid
  12. FROM prospectus
  13. WHERE prospectus.subid='".$grades."'
  14. ) and prospectus.sem=2
  15. ");
  16.         while($sub_row = mysql_fetch_array($race)){
  17.             //echo "".$sub_row['subid']."<br />";
  18.  
  19.  
  20.     $result2="select * from subject where subid='".$sub_row['subid']."' order by subid ASC limit 0,1";
  21.         $rsq2=mysql_query($result2);
  22.         while ($r2=mysql_fetch_array($rsq2)){
  23.         echo "<tr>";
  24.         echo "<td><input type=\"hidden\" name=\"subid[]\" value=\"".$r2['subid']."\"/>".$r2['subcode']."</td><td>".$r2['subname']."</td><td>".$r2['subdesc']."</td><td>".$r2['units']."</td></tr>"; 
  25.             }
  26.         }
  27.     }            
  28. }
  29.  
the output should be:
1
2
3
4
5
but it displays:
1
2
3
4
5
1
2
3
4
5
hope you can help me....
Feb 12 '12 #1
5 2038
Rabbit
12,516 Expert Mod 8TB
We would have to know what the data looks like.
Feb 12 '12 #2
i have 3 tables..GRADES, PROSPECTUS and SUBJECT..

the grade tables looks like this..
gid| idno |course|year|sem| syear |subid|grade|remarks|
1 |20110002|BSIT |1 | 1|2011-2012| 41 | 90 | passed|
2 |20110002|BSIT |1 | 1|2011-2012| 5 | 90 | passed|
3 |20110002|BSIT |1 | 1|2011-2012| 10 | 90 | passed|
4 |20110002|BSIT |1 | 1|2011-2012| 13 | 90 | passed|
5 |20110002|BSIT |1 | 1|2011-2012| 16 | 90 | passed|
6 |20110002|BSIT |1 | 1|2011-2012| 18 | 70 | failed|
7 |20110002|BSIT |1 | 1|2011-2012| 42 | 70 | failed|
8 |20110002|BSIT |1 | 1|2011-2012| 19 | 70 | failed|
9 |20110002|BSIT |1 | 1|2011-2012| 43 | 70 | failed|
10 |20110002|BSIT |1 | 1|2011-2012| 25 | 90 | passed|
11 |20110002|BSIT |1 | 1|2011-2012| 20 | 90 | passed|

PROSPECTUS table looks like this:
idpros|course|year|sem|subid|prerequisite1|
1 |BSIT |1 | 2| 24 | 19 |
2 |BSIT |1 | 2| 23 | 19 |
3 |BSIT |1 | 2| 17 | 16 |
4 |BSIT |1 | 2| 21 | 0 |
5 |BSIT |1 | 2| 14 | 0 |
6 |BSIT |1 | 2| 11 | 0 |
7 |BSIT |1 | 2| 6 | 0 |
8 |BSIT |1 | 2| 2 | 0 |
9 |BSIT |1 | 2| 26 | 25 |
10 |BSIT |1 | 2| 27 | 0 |

SUBJECT table look like this:

subid |subcode|subname|units|
41 |as12 |name1 | 3 |
23 |gh34 |name2 | 3 |
17 |jj22 |name3 | 3 |
21 |ko90 |name4 | 3 |
14 |78ju |name5 | 3 |
11 |990o |name6 | 3 |
6 |ty65 |name7 | 3 |
2 |asa8 |name8 | 3 |
26 |sd9d |name9 | 3 |
27 |sds9 |name10 | 3 |

hope this one can help...
Feb 13 '12 #3
Rabbit
12,516 Expert Mod 8TB
Your data doesn't match your previous post at all.
Feb 13 '12 #4
huh?? but the data i've posted is the same..??
Feb 13 '12 #5
Rabbit
12,516 Expert Mod 8TB
You posted that the result you're getting back is 1 2 3 4 5. But your code is actually printing out multiple values per row. That doesn't match. So I have no idea what you mean when you say it's printing back 1 2 3 4 5. When nothing in your code shows that it should print that.
Feb 13 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ron Hocking | last post by:
When I link a MySQL table containing a TIME column to Microsoft Access the value does not display. If I edit the value it updates correctly in mysql but if I refresh the Access datasheet view the...
2
by: Robert | last post by:
I have a label on my form lblCount and the following code in my form for displaying a record count: Private Sub Form_Current() Me.RecordsetClone.Bookmark = Me.Bookmark Me!lblCount.Caption =...
3
by: IraqiAli | last post by:
ok i have a couple of textboxes. The user is required to input values from 1 to 6 into those boxes. and submit it, those values would then go into an array. What i need to do is do checks to make...
0
by: Matthew87 | last post by:
Hi all I'm having a bit of trouble completeing my coursework basically so far i have created Citenary class with support methods for a private array. The problem is i can add objects to the array...
3
by: gemguy | last post by:
hi, I have a issue with an array values... Im having values repeatedly stored in an array and i want to delete those repeated values using javascript. * I tried it by storing in an array and...
33
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
1
by: hellboss | last post by:
Hi Every one ! im work with asp.net,vs05 My prob is, i have a set of values dynamically binded in listbox control with its datavaluefield to the Corresponding ID and dataTextfield to the text...
3
by: cmrhema | last post by:
Hello I am using C# and asp.net I have populated my list box Now when I select a value in the list box the relevant values should be displayed in the textbox Here's my code protected void...
7
by: vermarajeev | last post by:
Hello All, How do I display ASCII values from A..Z? I tried the following but get some compiler error: def DisplayAscii() for index in 'A'..'Z' do puts ?index end end
6
by: billelev | last post by:
This is probably very easy, but I can't see how you would do this... I have a table that is used as a source table for a report. The table contains percentage values. In the report, I would like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.