Vecteevs Posted October 8, 2011 Report Share Posted October 8, 2011 (edited) Sveiki, man ir problēma ar datu ievietošanu datubāzē no array. tātad pieņemsim man ir šads array Array( [0] => /viens [1] => /divi [2] => /trīs [3] => /četri [4] => /pieci ) Bet skaits var turpināties līdz pat 100 vai pat vairāk.Mēģināju ievietot datus šādi foreach($dati[1] as $cipari) ievietojas tikai pēdējais skaitlis.MMēģināju arī pašu array $dati[1]; Bet iekš db ievietojas tikai "Array".Kā var izdarīt lai ievietojas visi ieraksti?</pre> Edited October 8, 2011 by Vecteevs Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 8, 2011 Report Share Posted October 8, 2011 Nu kā... ja tev ir masīvs ($dati), tad kāpēc tu ej caur $dati[1], kas ir otrais masīva elements? foreach ($dati as $value) { do_stuff($value); } Quote Link to comment Share on other sites More sharing options...
Vecteevs Posted October 8, 2011 Author Report Share Posted October 8, 2011 Tā man ieliekas tikai pēdējais cipars datubāzē.. Bet man vajag lai ieliekas visi cipari un katrs savā row Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 8, 2011 Report Share Posted October 8, 2011 Nu patiešām ir tik grūti sakarīgi izstāstīt? Kādi dati? Kur tu tos iegūsti? Kāds cipars? Pēdējais?? Kādā tabulā? Kāpēc? Quote Link to comment Share on other sites More sharing options...
Vecteevs Posted October 8, 2011 Author Report Share Posted October 8, 2011 sorry.. :D tātad kods ir tāds $content = file_get_contents($domain.$url); preg_match_all($pattern, $content, $matches); foreach($matches[1] as $value){ echo "<b><font size=4>".$value."</font></b><br>"; Iegūstu content no kādas lapas un to vajag iemest manā datubāzē Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 8, 2011 Report Share Posted October 8, 2011 Nu? $matches[1] par $matches. Quote Link to comment Share on other sites More sharing options...
xfr33 Posted October 9, 2011 Report Share Posted October 9, 2011 varbūt ar for? x - tik liels tev masīvs. for($i=0;$i<=x;$i++){ ievietot datubāzē masivs[$i] } Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 9, 2011 Report Share Posted October 9, 2011 Tas jau neko nemaina. foreach ($dati as $key => $value) { 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.