soryn4u Posted September 2, 2011 Share Posted September 2, 2011 i have this code... and i want to make it more dynamic.... <?php $content = $content[1].$content[2].$content[3].$content[4].$content[5].$content[6].$content[7].$content[8].$content[9].$content[10].$content[11].$content[12] .$content[13].$content[14].$content[15].$content[16] .$content[17].$content[18].$content[19].$content[20].$content[21].$content[22].$content[23].$content[24]; $sql = mysql_query ("insert into database (content) values ('$content')") or die(mysql_error()); ?> for example... instead content[1]. content[2]. content[3] ...etc... i want something like this....... $content = $content[from 1 to 24]; or $content = $content[from 1 to 777]; any solutions? Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/ Share on other sites More sharing options...
Pikachu2000 Posted September 2, 2011 Share Posted September 2, 2011 What? Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/#findComment-1264856 Share on other sites More sharing options...
soryn4u Posted September 2, 2011 Author Share Posted September 2, 2011 which part you dont understand? i now.. i always...have ideas... who create confusion :confused: Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/#findComment-1264858 Share on other sites More sharing options...
Maq Posted September 2, 2011 Share Posted September 2, 2011 Loop through the size of the array and for each through it? Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/#findComment-1264861 Share on other sites More sharing options...
soryn4u Posted September 2, 2011 Author Share Posted September 2, 2011 the code works in that form...but i want a simple way...a dynamic way for example i have this.. <?php $number = 25; for ($i = 0; $i < $number; $i++){ echo $content[$i] = $xml->data[$i]; } //then i create this code...to be inserted into db $content = $content[1].$content[2].$content[3].$content[4].$content[5].$content[6].$content[7].$content[8].$content[9].$content[10].$content[11].$content[12] .$content[13].$content[14].$content[15].$content[16] .$content[17].$content[18].$content[19].$content[20].$content[21].$content[22].$content[23].$content[24]; $sql = mysql_query ("insert into database (content) values ('$content')") or die(mysql_error()); //but i dont like it... i want.... thist part --------> $content = $content[1].$content[2].$content[3].$content[4] ---> to be dynamic.. ?> Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/#findComment-1264863 Share on other sites More sharing options...
soryn4u Posted September 2, 2011 Author Share Posted September 2, 2011 :confused: Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/#findComment-1264868 Share on other sites More sharing options...
Pikachu2000 Posted September 2, 2011 Share Posted September 2, 2011 Why not implode? $content = implode ('', $content); Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/#findComment-1264881 Share on other sites More sharing options...
soryn4u Posted September 2, 2011 Author Share Posted September 2, 2011 thanks a lot .... Pikachu2000 ... it works... great ! Link to comment https://forums.phpfreaks.com/topic/246296-how-to-insert-this-codeinto-database/#findComment-1264885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.