Mighty Posted June 30, 2009 Report Share Posted June 30, 2009 Sveiki. Man ir datubāze ar dziesmu sarakstu (tur ir tikai 2 rows - id un links). Kā lai es piespiežu manu web-playeri atskaņot vienu dziesmu randomā no tām, kuras man ir datubāzē? Pagaidām man ir kkas šāds, bet nekas nesanāk - manipulējot ar kodu, vienīgais ko es varu izdarīt, ir panākt ka pleijerī (kurā vajag tikai padot adresi ar tiešo url, lai atskaņotu dziesmu) vainu skan dziesma, kurai ID = 1, vai arī neskan nekas. mysql_query("Select links from muzika ORDER BY RAND() LIMIT 1"); Būšu priecīgs par padomu. Quote Link to comment Share on other sites More sharing options...
Wuu Posted June 30, 2009 Report Share Posted June 30, 2009 mysql kods ir pareizs Quote Link to comment Share on other sites More sharing options...
marcis Posted June 30, 2009 Report Share Posted June 30, 2009 Jādomā, ka kļūda ir citur, jo mysql pieprasījums izskatās sastādīts pareizi. Quote Link to comment Share on other sites More sharing options...
Mighty Posted June 30, 2009 Author Report Share Posted June 30, 2009 Njā, labāk būtu pateikuši ka es esmu dumjš un dabūjis pareizo variantu. Caur Lapas Pirmkodu atradu (tur kur vajadzētu būt dziesmas url) - kkādu šitādu Resource id #12 Kas pie velna vēl tas ir? :( Quote Link to comment Share on other sites More sharing options...
Indian Posted June 30, 2009 Report Share Posted June 30, 2009 tu man liekas pa tieso izvadi mysql resultaatu Quote Link to comment Share on other sites More sharing options...
J0ke Posted June 30, 2009 Report Share Posted June 30, 2009 vo vo rādi šurp php kodu :> Quote Link to comment Share on other sites More sharing options...
Mighty Posted June 30, 2009 Author Report Share Posted June 30, 2009 Sanāca pašam :) Paldies par palīdzību saprotot ka pats vien biju vainīgs. Quote Link to comment Share on other sites More sharing options...
cucumber Posted June 30, 2009 Report Share Posted June 30, 2009 ORDER BY RAND() LIMIT 1 === source of evil labak izmanto visu skaitu randoma ierkastu. SELECT FLOOR(RAND() * COUNT(*)) AS rand_row FROM `myTable` WHERE 1; SELECT `id` FROM `myTable` WHERE 1 LIMIT ".$r['rand_row'].", 1; Quote Link to comment Share on other sites More sharing options...
bubu Posted June 30, 2009 Report Share Posted June 30, 2009 kam tur WHERE 1 vajadzīgs? Quote Link to comment Share on other sites More sharing options...
cucumber Posted July 1, 2009 Report Share Posted July 1, 2009 phpmyadmina rakstiju, tur tas where pec noklusejama stav, pec butibas var nerakstit, bet ja sql'a where nosacijums bus vajaddzigs, tad bus jau uzrakstits kam tur WHERE 1 vajadzīgs? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.