Devils666 Posted January 27, 2010 Report Share Posted January 27, 2010 $dabut = mysql_query("SELECT * FROM `daubssana` ORDER BY `id` ASC") or die(mysql_error()); while ($izvadu = mysql_fetch_array($dabut)) { echo $izvadu['id']; } Kā es visu izvadīto varētu massīvā dabūt? es vairākus variantus izmēģināju bet kaut kā neizdevās... :/ Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted January 27, 2010 Report Share Posted January 27, 2010 (edited) Tatad :) pirmāmkārtām jautājums vispirms, piemērs pēc tam. $dabut = mysql_query(...); while($izvadu = mysql_fetch_array($dabut)){ // $izvadu ir masivs :) } Edited January 27, 2010 by EdgarsA Quote Link to comment Share on other sites More sharing options...
Devils666 Posted January 27, 2010 Author Report Share Posted January 27, 2010 (edited) tā jau es mēgināju, visu laiku pārraksta vienu otram pa virsu un izvada tikai pēdējo tas būtu pārāk vienkārši bijis :D Edited January 27, 2010 by Devils666 Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted January 27, 2010 Report Share Posted January 27, 2010 es laikam isti nesapratu ko tu isti gribi panakt while($a = funkcija($b)) { .. } kur $a tiek izveidots ka masivs ko izveido funkcija izmantojot $b resulrsu Quote Link to comment Share on other sites More sharing options...
Devils666 Posted January 27, 2010 Author Report Share Posted January 27, 2010 (edited) $dabut = mysql_query("SELECT * FROM `daubssana` ORDER BY `id` ASC") or die(mysql_error()); while ($izvadu = mysql_fetch_array($dabut)) { $massivs = $izvadu['id']; //ja tā varetu butu labi, bet.... } būtībā lai izvadot šo te, parādās vairāki ieraksti ar echo, bet ja ielikt masīva tikai viens no viņiem man to sanāk bāzt visam manam lielajam echo''; pa vidu labak butu nolikt kaut kur malā, ievietojoo masīvā un pataisno ielikt lielajā echo'' nevis kaut kādus kodus likt pa vidu tam ok, kā jau dažs labs ir teicis, skaidrošana nav mana stipra puse :D :D Edited January 27, 2010 by Devils666 Quote Link to comment Share on other sites More sharing options...
2easy Posted January 27, 2010 Report Share Posted January 27, 2010 $dabut = mysql_query("SELECT * FROM `daubssana` ORDER BY `id` ASC") or die(mysql_error()); while ($izvadu = mysql_fetch_array($dabut)) { $a[] = $izvadu['id']; } Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted January 27, 2010 Report Share Posted January 27, 2010 aa ta domaja ? :D sry.. Quote Link to comment Share on other sites More sharing options...
Devils666 Posted January 27, 2010 Author Report Share Posted January 27, 2010 $dabut = mysql_query("SELECT * FROM `daubssana` ORDER BY `id` ASC") or die(mysql_error()); while ($izvadu = mysql_fetch_array($dabut)) { $a[] = $izvadu['id']; } sākuma, man līdzīga doma bija, bet es nemācēju pareizi ielikt iekš echo''; vislaik errorus meta un tagad tāpat Quote Link to comment Share on other sites More sharing options...
2easy Posted January 27, 2010 Report Share Posted January 27, 2010 kādus tieši errorus? Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted January 27, 2010 Report Share Posted January 27, 2010 <?php $masivs = array(); $query = mysql_query("SELECT * FROM `daubssana` ORDER BY `id` ASC") or die(mysql_error()); while($row = mysql_fetch_array($query)){ if(!in_array($row['id'],$masivs)) $masivs[]=$row['id']; } # tad kad gribi taisit echo izmanto kadu no shiem # --- # Print echo "<pre>"; print_r($masivs); echo "</pre>"; # Dump var_dump($masivs); # Vai foreach foreach($masivs as $a=>$id){ echo "Masivs id numeralis ir {$a} ar vertibu {$id}<br>"; }?> Quote Link to comment Share on other sites More sharing options...
2easy Posted January 27, 2010 Report Share Posted January 27, 2010 kāpēc tu visu laiku posto pāris sekundes pēc manis? :D:D:D Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted January 27, 2010 Report Share Posted January 27, 2010 tā tam ir jābūt! :) Quote Link to comment Share on other sites More sharing options...
Devils666 Posted January 27, 2010 Author Report Share Posted January 27, 2010 (edited) jā, šķiet tas ir tas ko biju domājis :) laikam kodu praksē kaut kad pa dienu pamēģināsu pielietot :D bet nu strādātu ja es izdarītu apmēram, tā $massiiva_forma = 'Šis massivs izvada nummuru - '.$row['id'].' bla bla bla'; if(!in_array($row['id'],$masivs)) $masivs[]=$massiiva_forma; un pie reizes jautājums bišk offtopika - kapēc te smaiļiki neiet? precīzāk, kapēc vini ir atslēgti? :D Edited January 27, 2010 by Devils666 Quote Link to comment Share on other sites More sharing options...
EdgarsK Posted January 27, 2010 Report Share Posted January 27, 2010 iet :) tikai ne grafiski :) mes esam programmetaji nevis chata friki ;) Quote Link to comment Share on other sites More sharing options...
Devils666 Posted January 27, 2010 Author Report Share Posted January 27, 2010 ok, bet bišk skumiji izskatas tie koli un iekavas, bet tas tā :D "tikai ne grafiski" tas ir kā domāts? 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.