Solved_ Posted July 21, 2012 Share Posted July 21, 2012 I get a random number of database results (based on some criteria). Now I want to add two more pieces to the array, that are always the same, Key = 3 Value is "part 1" and key = 5 value = "part2", I use $number from database as KEY, that are always even numbers. Now I want to create a array that mix the pieces from the database with the two static parts. I am a bit of a beginner, how can I add two parts, without adding them multiples everytime the loop runs? $result = mysql_query('SELECT * FROM table') or exit(mysql_error()); $number = mysql_query('SELECT * FROM table') or exit(mysql_error()); while ($row = mysql_fetch_assoc($result)) {$array[$number] = $row;} print_r($array); Link to comment https://forums.phpfreaks.com/topic/266038-building-array-from-database-add-two-standard-parts/ Share on other sites More sharing options...
Barand Posted July 21, 2012 Share Posted July 21, 2012 add them after the loop has completed Link to comment https://forums.phpfreaks.com/topic/266038-building-array-from-database-add-two-standard-parts/#findComment-1363239 Share on other sites More sharing options...
Solved_ Posted July 21, 2012 Author Share Posted July 21, 2012 thanks! brilliantly simple, just started with php, so I can add things to the array afterwards. Link to comment https://forums.phpfreaks.com/topic/266038-building-array-from-database-add-two-standard-parts/#findComment-1363242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.