Advertisement
alchymyth

shortcode with table

Oct 5th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. function CountyInstancesOver30($gallery=1) {
  2. global $wpdb;
  3. $sql = "SELECT County, COUNT(County) AS Incident FROM tblSpeedData WHERE Speed > 30";
  4. $result = $wpdb->get_results($sql);
  5. if( $result ) {
  6.     $output = "<table>\n";
  7.     foreach ($result as $pic)
  8.     {
  9.     $output .= "<tr><td>County: " . $pic->County . "</td><td>Incidents: " . $pic->Incident . "</td></tr>\n";
  10.     }
  11. $output .= "</table>\n";
  12. }
  13. return $output;
  14. }
  15. add_shortcode('CInstO30', 'CountyInstancesOver30');
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement