[PHP] waarde 1 maal weergeven uit database

Pagina: 1
Acties:
  • 82 views sinds 30-01-2008

  • ikker
  • Registratie: Oktober 2001
  • Laatst online: 02-09 16:30

ikker

No Risk No Pain No Fun!!!

Topicstarter
ik heb een database guvuld met de volgende gegevens

+------+--------+------------------+------------------+
| code | softid | pakkettitel | versie |
+------+--------+------------------+------------------+
| 53 | 3 | Microsoft office | XP |
| 54 | 3 | Microsoft office | XP |
| 52 | 2 | Sophos | 5.02 |
| 56 | 3 | Sophos | 5.02 |
| 51 | 2 | Winzip | 8.0 |
| 50 | 1 | Microsoft office | XP |
| 55 | 3 | microsoft office | 2000 |
| 64 | 0 | Microsoft | works suite 2002 |
| 49 | 1 | Norton antivirus | 2000 |
| 57 | 3 | Winzip | 8.0 |
| 58 | 4 | microsoft office | 2000 |
| 59 | 4 | Norton antivirus | 2000 |
| 60 | 5 | Microsoft office | XP |
| 61 | 5 | microsoft office | 2000 |
| 62 | 5 | Norton antivirus | 2000 |
| 63 | 5 | Winzip | 8.0 |
| 65 | 0 | microsoft office | 2000 |
| 66 | 0 | Norton antivirus | 2000 |
+------+--------+------------------+------------------+

nu gaat het me om het weergeven van softid.
dit doe ik nu op de volgende manier
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?
  
$query = "SELECT softid FROM softid_tbl ORDER BY softid DESC";
$result = mysql_query($query);
         
for ($i = mysql_num_rows($result) - 1; $i >=0; $i--) {
 if (!mysql_data_seek($result, $i)) {
   printf ("Cannot seek to row %d\n", $i);
   continue; 
 }

 if (!($row = mysql_fetch_object($result)))
   continue;
 
   printf ("<OPTION VALUE=\"$row->softid\">%s\n", $row->softid);
?>

alleen geeft dit hetvolgende weer:

--------+
| softid |
+--------+
| 0 |
| 0 |
| 0 |
| 1 |
| 1 |
| 2 |
| 2 |
| 3 |
| 3 |
| 3 |
| 3 |
| 3 |
| 4 |
| 4 |
| 5 |
| 5 |
| 5 |
| 5 |
+--------+
dit moet echter zo worden

------
softid
------
1
2
3
4
5
------

wie kan mij vertellen hoe ik dit aanpas?

Mijn netwerkje


  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

www.mysql.com group by

Doet iets met Cloud (MS/IBM)


  • [ti]
  • Registratie: Februari 2000
  • Niet online
of evt. SELECT DISTINCT

  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

of even kijken in een manual..

Dit topic is gesloten.