Ugga Posted April 13, 2004 Report Share Posted April 13, 2004 man ir tabula files tur ir lauki artist,song,text. ir vajadziba uztaisiit skriptu, kas panjem visas rindas un prieksh katra artista saskaita cik vinjam ir songu. PS artist nav zinaams. skripts atrod visus iespeejamos artist un tad katram artist saskaita dziesmas. beigaas ir doma izveidot statistiku ar visu artistu sarakstu un dziesmu skaitu. kaa to vareetu panaakt? :unsure: Link to comment Share on other sites More sharing options...
bubu Posted April 13, 2004 Report Share Posted April 13, 2004 a kam mysql manuaalis domaats? SELECT artist, COUNT(*) FROM tabula GROUP BY artist Link to comment Share on other sites More sharing options...
trinklins Posted April 13, 2004 Report Share Posted April 13, 2004 nezinu cin nu labi tas ir pēc manām domām labāk ir izveidot divas tabulas vienā glabājas id, artist un otrā tabulā glabājas id, song, text un norāde jeb id_artist no pirmās tabulas Link to comment Share on other sites More sharing options...
Ugga Posted April 13, 2004 Author Report Share Posted April 13, 2004 tu domaa dziesmu skaitu skaitiit ar roku? t.i. ja pievieno jaunu tad dziesmu_skaits++;?? Link to comment Share on other sites More sharing options...
trinklins Posted April 13, 2004 Report Share Posted April 13, 2004 (edited) nee tjipa taaa artistus vienaa un dzismas otraa ---------------------------- tabula1 pk_artist artist ---------------------------- tabula2 pk_song song text fk_artist --------------------------- $sql= mysql_query("select * from tabula1"); while ($row = mysql_fetch_array($sql)) { $pk_artist = $row['pk_artist']; $artist = $row['artist']; $sql_skaits = mysql_query("SELECT COUNT(fk_artist) as skaits FROM tabula2 WHERE fk_artist = '$pk_artist'"); $row2 = mysql_fetch_array($sql_skaits); $skaits = $row2['skaits']; echo $artist ."ir tāds".$skaits."dziesmu skaits<br>"; } nu kautkā tā :rolleyes: Edited April 13, 2004 by trinklins Link to comment Share on other sites More sharing options...
bubu Posted April 13, 2004 Report Share Posted April 13, 2004 ja lieto trinklina db struktuuru, tad labaak shaadi: SELECT pk_artist, artist, COUNT(*) FROM tabula1, tabula2 WHERE pk_artist=fk_artist GROUP BY pk_artist, artist Link to comment Share on other sites More sharing options...
Ugga Posted April 14, 2004 Author Report Share Posted April 14, 2004 paldies, nomeeginaashu! B) Link to comment Share on other sites More sharing options...
Recommended Posts