rohan.bajaj17 Posted July 24, 2012 Share Posted July 24, 2012 please give me answer 18707_.php 18708_.php Quote Link to comment https://forums.phpfreaks.com/topic/266168-how-to-get-one-by-one-element-from-array-and-store-one-by-one-in-databse/ Share on other sites More sharing options...
gristoi Posted July 24, 2012 Share Posted July 24, 2012 answer to what? . you havent explained what the problem is or what you have tried already to resolve the problem? Quote Link to comment https://forums.phpfreaks.com/topic/266168-how-to-get-one-by-one-element-from-array-and-store-one-by-one-in-databse/#findComment-1363987 Share on other sites More sharing options...
cyberRobot Posted July 24, 2012 Share Posted July 24, 2012 You would loop through the array using something like foreach(): http://php.net/manual/en/control-structures.foreach.php Inside the loop, you would run the code to save each entry to the database. Quote Link to comment https://forums.phpfreaks.com/topic/266168-how-to-get-one-by-one-element-from-array-and-store-one-by-one-in-databse/#findComment-1363988 Share on other sites More sharing options...
rohan.bajaj17 Posted July 25, 2012 Author Share Posted July 25, 2012 [<?php $f="F"; $Cnt=1; $var=4; $var2=$var; $var1=66; $var5=65; $myarray=array(); if($var==100 || $var==200) { $var2=1; $var1++; echo$var1; $var5++; echo$var5; } if($var1<93) { for($s=$var5;$s<$var1;$s++) { $char=chr($s); if($var2<100) { for($i=0;$i<$var2;$i++) { $String=$f.$char.$Cnt; //echo $String; array_push($myarray,$String); //foreach( $myarray as $key => $value) $keys = array_keys($myarray); //$lastKey = end($keys); //echo$lastKey; reset($myarray); //Safety - sets pointer to top of array $firstKey = key($myarray); // Returns the first key of it echo "Key = ".$firstKey; echo "<br>"; $Cnt++; } } } //break; $Cnt=1; } //$flag=1; ?> i already generated code like FA1 ...FA99 ....FB1 ...FB99 ...FZ1...FZ99.....i already stored in an array..u can see in above code. so i want to retrieve values one by one firstly fa1 and the fa2 and den fa3 and so on and fa1 store into database when i m trying to get keys one by one...bt it will print one key many times.... 18712_.php 18713_.php Quote Link to comment https://forums.phpfreaks.com/topic/266168-how-to-get-one-by-one-element-from-array-and-store-one-by-one-in-databse/#findComment-1364166 Share on other sites More sharing options...
cpd Posted July 25, 2012 Share Posted July 25, 2012 Your code is unreadable because you've just slapped it on here with an abysmal explanation. I don't mean to be harsh but if you want help, first help yourself by taking the time to write a decent explanation, with examples, describing your problem. Then, maybe, someone will answer appropriately and solve your problem. I personally can't even be bothered to look at your code at the moment. Quote Link to comment https://forums.phpfreaks.com/topic/266168-how-to-get-one-by-one-element-from-array-and-store-one-by-one-in-databse/#findComment-1364172 Share on other sites More sharing options...
hakimserwa Posted July 25, 2012 Share Posted July 25, 2012 do you know the position of the exact data that you would like in a specific table field? is yes then run a foreach loop and catch the values into a variable. $a = array(1,2,3,4) foreach($a as $ab){ $c=$ab[0]; $d = $ab[1]; $e = $ab[2]; $f = $ab[3]; } the save the vatriable c d e f in your data base. Quote Link to comment https://forums.phpfreaks.com/topic/266168-how-to-get-one-by-one-element-from-array-and-store-one-by-one-in-databse/#findComment-1364175 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.