How do I put a query on the front page?

How do I put a query on the front page?

J m - келді
Number of replies: 4

If there's a beginner link to help, sorry, but all I want to do is put the results of a query on the front page.

I am able to do simple things like echo $USER->id, but what if I want to do something very simple like query with that userid?  All I need is a simple example like select the users information, just so I can see how it fits together.  A hello world from the database.  I started to just add my own mysql connection strings, but that didn't make sense, wanted to do it right.

Any hand holding is appreciated.  Thank you.

In reply to J m

Re: How do I put a query on the front page?

Gordon Bateson - келді
Core developers қатысушының суреті Peer reviewers қатысушының суреті Plugin developers қатысушының суреті
> all I want to do is put the results of a query on the front page

You can't use PHP in the standard Moodle blocks and course descriptions, so you would have to write your own block.

The following information may be useful for you:
http://docs.moodle.org/en/Development:Blocks

Gordon
In reply to J m

Re: How do I put a query on the front page?

Martin Dougiamas - келді
Core developers қатысушының суреті Documentation writers қатысушының суреті Moodle HQ қатысушының суреті Particularly helpful Moodlers қатысушының суреті Plugin developers қатысушының суреті Testers қатысушының суреті
Try this for a start (put it in the Moodle home directory):

<?php require('config.php'); require_login(); print_object($USER); /// global object that is always available for logged in users $user = get_record('user', $USER->id); /// Getting a record from a db table if ($user) { print_object($user); /// what the plain record looks like } else { error('No user found! This should never happen.'); } ?>
In reply to Martin Dougiamas

Re: How do I put a query on the front page?

Hassani Hachim - келді
hello martin,
I tried this code and got an error. Then i changed this line $user = get_record('user', $USER->id); to $user = get_record('user', 'id',$USER->id);
Now it works.
Actually i'm interested in way to make my own php page.
A couple of days ago, i wrote my first modules and blocks but i don't know how to do if i want to call an existing block (eg online users, calender block). I've tried several methods like $mybloc = block_instance('block_calender')..., but it doesn't work. Now i'm on page 7 of this general developer forum but i can't find a solution, maybe you could help me (if you have a little time, i would really apreciate)