Need help deciphering an array with FOREACH elements

Discussion in 'PHP' started by nullpoint81, Oct 20, 2012.

  1. #1
    Hey everyone!

    I just need a little help expanding and deciphering this PHP array so I can configure the results myself.

    The query is a simple SELECT * from _____

    All the results are placed into this array, which then formats the results in a table (pardon the somewhat ghetto look of this code).

    Basically, the issue now is that each result prints as follows:

    NAME
    ClickableNAMEofVenue <--- a url

    I would like to know how to pull individual results from the array and be able to display the data directly next to the ClickableNAMEofVenue since there is data in the array that goes undisplayed.

    Hopefully I've explained this is a helpful way. Any assistance would be much appreciated. Thanks!

    
    $qry_result = mysql_query($query) or die(mysql_error());
    
    
        $places = array();
    while($row = mysql_fetch_array($qry_result))
    {
        $places[$row['area']]
        
        [$row['server_url']] = $row['name'];
        
    }
    
    
        foreach ($places as $place => $d)
        {
            echo "<table id=display_results_table_bar width=100%>";
            echo "<tr>";
            echo "<th id=query_result_zip>$place</th>";
            echo "</tr>";
            foreach ($d as $n => $r)
            {
            echo "<tr>";
            echo "<td id=query_result_name><a href=# onclick=loadNewPage('$n') class=ajaxDiv; > $r </a></td>";
            echo "</tr>";
    
            }
            
        }
    
        echo "</table>";
    
    Code (markup):
     
    nullpoint81, Oct 20, 2012 IP
  2. knewedge

    knewedge Active Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #2
    I'm not sure if I completely understand you, but your problem might be related to having your key and value separated by your for loop.
     
    knewedge, Oct 27, 2012 IP