You can copy & paste following php code for every where
$con = mysql_connect("hostname","username","password");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("moodledatabase", $con) or die(mysql_error());
$query_course_list = "SELECT c.id AS courseid, c.fullname FROM mdl_course c where category != 0";
$courses = mysql_query($query_course_list);
$output = '- ';
while ($course = mysql_fetch_object($courses)){
$output .= '
- '; $output .= ''; $output .= $course->fullname; $output .=' '; } $output .= '