Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: None  |  size: 1.33 KB  |  views: 26  |  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. $query = mysql_query("SELECT Provider.provider_id, provider.company_name FROM Provider");
  2.  
  3. while($row = mysql_fetch_array($query)){
  4.     echo "'".$row['provider_id']."':'".$row['company_name']."',";
  5.  
  6. }
  7.        
  8. $query = ...;
  9. $out = Array();
  10. while($row = mysql_fetch_assoc($query)) {
  11.     $out[] = "'".$row['provider_id']."':'".$row['company_name']."'";
  12. }
  13. echo implode(",",$out);
  14.        
  15. $query = ...;
  16. $out = Array();
  17. while($row = mysql_fetch_assoc($query)) {
  18.     $out[$row['provider_id']] = $row['company_name'];
  19. }
  20. echo json_encode($out);
  21.        
  22. $parts = array();
  23. while($row = mysql_fetch_array($query)){
  24.     $parts[] =  "'".$row['provider_id']."':'".$row['company_name']."'";
  25.  
  26. }
  27.  
  28. echo implode(',', $parts);
  29.        
  30. $data = array();
  31. while($row = mysql_fetch_array($query)){
  32.     $data[$row['provider_id']] = $row['company_name'];
  33.  
  34. }
  35.  
  36. echo json_encode($data);
  37.        
  38. $query = mysql_query("SELECT Provider.provider_id, provider.company_name FROM Provider");
  39. $result = "";
  40. while($row = mysql_fetch_array($query)){
  41.     $result .= "'".$row['provider_id']."':'".$row['company_name']."',";
  42. }
  43. $result = rtrim($result, ',');
  44.        
  45. $query = mysql_query("SELECT Provider.provider_id, provider.company_name FROM Provider");
  46. $result = array;
  47. while($row = mysql_fetch_array($query)){
  48.     $result[] = "'".$row['provider_id']."':'".$row['company_name']."',";
  49. }
  50. $result = implode(',' $result);
clone this paste RAW Paste Data