Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 23rd, 2012  |  syntax: None  |  size: 1.97 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Using form data as known key value when echoing a multidimensional array
  2. $lettertype = str_split($lettertype);  
  3. $lettertype = "'" . implode("','", $lettertype) . "'";      
  4. $query = "SELECT * FROM Photos WHERE letter IN ($lettertype)";
  5. $result = mysqli_query($cxn, $query)
  6.   or    die ("No good");    
  7. $alpharray = array();
  8. while($row = mysqli_fetch_assoc($result)){
  9.     $alpharray[$row['letter']][] = $row;
  10. }
  11. foreach(str_split($_POST['search_term']) as $alpha){          
  12.     echo "<img class='clickable' img src='../Letterproject/images/{$alpharray[$alpha][0]['photoPath']}' width='100' height='140'></src>";          
  13.     echo '<div class="editimages">';                    
  14.     foreach ($alpharray as $tempvar){                  
  15.         foreach($tempvar as $oneletter){                      
  16.             echo "<img class='editable' img src='../Letterproject/images/{$oneletter['photoPath']}' width='100' height='140'></src>";                                      
  17.         }
  18.     }              
  19.     echo '</div>';        
  20. }
  21.        
  22. "SELECT * FROM Photos WHERE letter IN ($lettertype)";
  23.        
  24. $lettertype = str_split($lettertype);  
  25. $lettertype = "'" . implode("','", $lettertype) . "'";      
  26. $query = "SELECT * FROM Photos WHERE letter IN ($lettertype)";
  27. $result = mysqli_query($cxn, $query)
  28.   or    die ("No good");    
  29. $alpharray = array();
  30. while($row = mysqli_fetch_assoc($result)){
  31.     $alpharray[$row['letter']][] = $row;
  32. }
  33. foreach(str_split($_POST['search_term']) as $alpha){          
  34.     echo "<img class='clickable' img src='../Letterproject/images/{$alpharray[$alpha][0]['photoPath']}' width='100' height='140'></src>";          
  35.     echo '<div class="editimages">';                    
  36.     foreach ($alpharray[$alpha] as $tempvar){                                      
  37.             echo "<img class='editable' img src='../Letterproject/images/{$tempvar['photoPath']}' width='100' height='140'></src>";                                      
  38.     }              
  39.     echo '</div>';        
  40. }