zintis8789 Posted November 9, 2009 Report Share Posted November 9, 2009 (edited) Es meklēju skriptu kas izvilks no db pretinieka komandu jauktaa secībā. Parasti radas: Mana komanda VS K1 Mana komanda VS K2 Mana komanda VS K3 Mana komanda VS K4 utt. Bet vajag: Mana komanda VS K1 K2 VS Mana komanda K3 VS mana komanda Mana komanda VS K4 utt. Edited November 9, 2009 by zintis8789 Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted November 9, 2009 Report Share Posted November 9, 2009 beigās ieliec ORDER BY RANDOM() Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted November 9, 2009 Author Report Share Posted November 9, 2009 Bet kā lai es izdaru tā ka 1 rindā ir labajā pusē mana komanda bet otrajā rindā mana komanda ir kreisajā pusē? Quote Link to comment Share on other sites More sharing options...
Alnis Posted November 10, 2009 Report Share Posted November 10, 2009 $pretinieku_komanda= array("Warriors", "Suns", "Pistons", "Knicks", "Buls"); $tava_komanda="Wizards"; $skaits=count($pretinieku_komanda); FOR($i=0;$i<10;++$i){ $rand=RAND(0,($skaits-1)); $pretinieks=$pretinieku_komanda[$rand]; //echo 'nejauša izvēle: '.$pretinieks; echo '<br>'; $rand2=rand(0,1); IF($rand2==1) echo $tava_komanda.' VS '.$pretinieks; else echo $pretinieks.' VS '.$tava_komanda; } Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted November 10, 2009 Author Report Share Posted November 10, 2009 :( Tikai viena problēma es vēlētos lai kad refrešoju logu nemainas nekas ;( Quote Link to comment Share on other sites More sharing options...
anonīms Posted November 10, 2009 Report Share Posted November 10, 2009 tad varbūt derētu noņemt rand, ne? Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted November 10, 2009 Author Report Share Posted November 10, 2009 A varbūt, Tad kad es nonemu rand man vairs neradas jauktā secībā :( Quote Link to comment Share on other sites More sharing options...
Alnis Posted November 10, 2009 Report Share Posted November 10, 2009 nu bet isii, rand datus inserto DB un pec tam nolasi :) Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted November 11, 2009 Author Report Share Posted November 11, 2009 Velviena problema :( Komandu speles atkartojas bet kaa lai izdara taa ka viņas neatkārtojas :( Man radas: Buls VS Wizards Wizards VS Knicks Wizards VS Pistons Knicks VS Wizards Buls VS Wizards Warriors VS Wizards Warriors VS Wizards Wizards VS Suns Wizards VS Warriors Wizards VS Knicks Quote Link to comment Share on other sites More sharing options...
Alnis Posted November 11, 2009 Report Share Posted November 11, 2009 GLOBAL $pretinieku_komanda; GLOBAL $tava_komanda; GLOBAL $skaits; GLOBAL $jau_izspeletas_speles; $pretinieku_komanda= array("Warriors", "Suns", "Pistons", "Knicks", "Buls"); $tava_komanda="Wizards"; $skaits=count($pretinieku_komanda); $jau_izspeletas_speles=array(); spelu_genarators(); function spelu_genarators(){ GLOBAL $pretinieku_komanda; GLOBAL $tava_komanda; GLOBAL $skaits; GLOBAL $jau_izspeletas_speles; $rand=RAND(0,($skaits-1)); $pretinieks=$pretinieku_komanda[$rand]; //echo 'nejauša izvēle: '.$pretinieks; //echo '<br>'; $rand2=rand(0,1); IF($rand2==1){ foreach($jau_izspeletas_speles as $value) { if($value== $tava_komanda.' VS '.$pretinieks){ ++$u; // ja spele jau ir izspeleta, tad $u bus lielaks par 0 } } if($u==0){ echo '<br />'.$tava_komanda.' VS '.$pretinieks; $spele= array(0=>$tava_komanda.' VS '.$pretinieks); $jau_izspeletas_speles=array_merge($jau_izspeletas_speles, $spele); unset($spele); } $u=0; } else { foreach($jau_izspeletas_speles as $value) { if($value== $pretinieks.' VS '.$tava_komanda){ ++$u; // ja spele jau ir izspeleta, tad $u bus lielaks par 0 } } if($u==0){ echo '<br />'.$pretinieks.' VS '.$tava_komanda; $spele= array(0=>$pretinieks.' VS '.$tava_komanda); $jau_izspeletas_speles=array_merge($jau_izspeletas_speles, $spele); unset($spele); } $u=0; } sub_generators(); } function sub_generators(){ GLOBAL $skaits; GLOBAL $jau_izspeletas_speles; if(count($jau_izspeletas_speles)<(($skaits)*2)) spelu_genarators(); } Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted November 11, 2009 Author Report Share Posted November 11, 2009 Ty 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.