Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts

    creating an array from data read from a db

    hello, I am trying to create an array from data read from a db. I am using the following code.
    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
    Code:
    $adx = array($tempadx);
    is where I think I am having the problem, I have tried using
    Code:
     $adx = array(1,$tempadx);
    but when I echo out $adx, I get a 1 and then the adx.

    thanks.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try:
    PHP Code:
    $adx[] = $tempadx
    Or, is you speifically want the array element to have the numerical index 1:
    PHP Code:
    $adx = array(=> $tempadx); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •