Newsletters

[insert_php]
global $wpdb;
$results = $wpdb->get_results( ‘SELECT * FROM `wp_rg_lead_detail` WHERE form_id = 3 ORDER BY lead_id ASC’, ARRAY_A );

if ( $results )
{
// echo sizeof( $results );
$rows = [];
//for ($i = 1; $count = 600, $i < $count; $i ++) { //if ($results[$i]['lead_id'] == $i) { foreach ($results as $result) { if ($result['field_number'] == 5) { $year = $result['value']; // echo $year; } if ($result['field_number'] == 4) { $month = $result['value']; switch ($month) { case "January": $nmonth = "01"; break; case "February": $nmonth = "02"; break; case "March": $nmonth = "03"; break; case "April": $nmonth = "04"; break; case "May": $nmonth = "05"; break; case "June": $nmonth = "06"; break; case "July": $nmonth = "07"; break; case "August": $nmonth = "08"; break; case "September": $nmonth = "09"; break; case "October": $nmonth = "10"; break; case "November": $nmonth = "11"; break; case "December": $nmonth = "12"; break; } // echo $month; } if ($result['field_number'] == 3) { $link = $result['value']; } if ($year && $nmonth) { $monthyear = "{$year}{$nmonth}"; } if ($link && $monthyear && $month && $year) { $row = "{$monthyear},{$year},{$month},{$link}"; $rows[] = $row; unset($row); unset($link); unset($year); unset($month); unset($nmonth); } // echo $link; // echo $monthyear; } // echo $row; // echo ' ‘, $month, ‘ ‘, $year, ‘ District 24 Newsletter

‘;
// }
// }
echo ‘

‘;
// echo count($rows);
rsort($rows);

foreach ( $rows as $entry ) {
$fields = explode (“,”, $entry);
echo ‘

‘;
}
echo ‘

‘, $fields[2], ‘ ‘, $fields[1], ‘ District 24 Newsletter

‘;
}

[/insert_php]