Forum Moderators: coopster

Message Too Old, No Replies

Looping database values to create an array

         

jamo101

12:21 pm on Dec 15, 2006 (gmt 0)

10+ Year Member



Hello everyone, I have a fairly simple php code problem I think, I want to loop values from a mysql database within an array to fill the array. I'v never done this before so your help would be valued if someone had the time.

*denotes where I want to use database values*

<?php
$days = array(
loop
*my_database_value*=>array('http://mysite/my_page.php?=*my_database_variable*'),
end loop
);
?>

Thanks for reading.

JG

mattcg

2:22 pm on Dec 15, 2006 (gmt 0)

10+ Year Member



Here's my suggestion:


$days = array();
while($row = mysql_fetch_assoc($result)) {
array_push($days, "http://mysite/my_page.php?=:{$row['mycolumn']}");
}