...

View Full Version : creating an array from data read from a db



davehaz
06-25-2005, 02:00 PM
hello, I am trying to create an array from data read from a db. I am using the following code.


foreach ($multimls as $key => $mls){
$sql= "SELECT * FROM listings WHERE mls = '$mls'";
$result = mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}else
while ($line = mysql_fetch_assoc($result)) {
$_SESSION['lockbox'] = $line['lockbox'];
$_SESSION['occupant'] = $line['occupancy'];
$_SESSION['directions'] = $line['directions'];
$_SESSION['combo'] = $line['combo'];
$_SESSION['showinginst'] = $line['showinginst'];
$_SESSION['stnum'] = $line['stnum'];
$_SESSION['stname']= $line['stname'];
$tempadx = $_SESSION['stnum']." ".$_SESSION['stname'];
$adx = array($tempadx);
}}

the
$adx = array($tempadx); is where I think I am having the problem, I have tried using
$adx = array(1,$tempadx); but when I echo out $adx, I get a 1 and then the adx.

thanks.

delinear
06-25-2005, 02:04 PM
Try:

$adx[] = $tempadx;
Or, is you speifically want the array element to have the numerical index 1:

$adx = array(1 => $tempadx);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum