Jump to content

Building array from database + add two standard parts


Solved_

Recommended Posts

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);  

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.