Jump to content

Help in fetching results from database.


spyer

Recommended Posts

Good day,

how are you doing? great i hope  :)

will, this is the problem i'm facing:

[color=red]TABLE CONTENTS:[/color]
[color=red]-------------------------------------------------[/color]
        |  yid  |  year  |  mid  |    month    |
[color=red]-------------------------------------------------[/color]
        |  1  |  2006  |    1  |  November  |
[color=red]-------------------------------------------------[/color]
        |  1  |  2006  |    2  |  December  |
[color=red]-------------------------------------------------[/color]
        |  2  |  2007  |    3  |    January    |
[color=red]-------------------------------------------------[/color]


[color=red]TABLE STRUCTURE:[/color]
[color=red]---------------------------------------------------------------------------[/color]
        |    yid    |      int(12)      |  UNSIGNED  |                          |
[color=red]---------------------------------------------------------------------------[/color]
        |    year    |  varchar(100)  |                  |                          |
[color=red]---------------------------------------------------------------------------[/color]
        |    mid    |      int(12)      |  UNSIGNED  |  auto_increment  |
[color=red]---------------------------------------------------------------------------[/color]
        |  month  |  varchar(100)  |                  |                          |
[color=red]---------------------------------------------------------------------------[/color]


[color=red]USED CODE:[/color]
[code]
<?php
$yl = mysql_query("SELECT * FROM list");

while ($blah = mysql_fetch_array($yl)) {

echo "$blah[year]<br>";
}
?>
[/code]


[color=red]PRINTED RESULTS:[/color]
2006
2006
2007

---- END ----

above you'll see the printed results where the year [color=blue](2006)[/color] is dublicated.. and this is because the year id [color=blue](yid)[/color] has the same value [color=blue](1)[/color].

I need the get the results and print them without dublicating any value.

Thank you very much, and sorry for the long speech  :-[
Link to comment
https://forums.phpfreaks.com/topic/29302-help-in-fetching-results-from-database/
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.