Ning Developer Network

Ennis Olson

New to PHP

I'm new to PHP and would like to read up on some basics. Can anyone recommend resources for learning PHP?

Also, I'd like to know how to write a basic query for a specific field for the members on my site. I've gone through the tutorials, but it would be helpful to see a complete php file with a basic query that I can execute.

Can anyone help me out?

thanks!

Tags: php, query

Reply to This

Replies to This Discussion

Ennis - as far as PHP resources are concerned, you may want to start with the following:
http://www.webmonkey.com/tutorial/PHP_Tutorial_for_Beginners
http://php.net/

(If anyone has any better resources - and I'm sure you guys do - feel free to chip in.) As far as basic queries, what kind of examples are you going for? -Ernie

Reply to This

Thanks Ernie - I'll take a look those sites.

I'm just looking for something that returned data on a user. For example, I know the bithdate info is stored as my.birthdate. what would a php file look like that would query that field and display the results. i'm just trying to understand syntax, so even if I could just put a birthdate.php file in my root directory which only runs a query that pulls values from that field would be enough.

thanks for the help - much appreciated!

Reply to This

Hi there Ennis. Okay, I wrote up a tiny program that uses an XN_Query object (the way we get stuff from the database within Ning - specifically for Ning at that) to do just that. I attached it as a file, and if you'd like, you can SFTP the program into your root directory of your social network and run it as a PHP file that way, just to see what it does.

Here's the text of the code:

<?php

/* We're using a XN_Query command that will pull out
All content, of type 'USER', or all user objects. */
$results = XN_Query::create('Content')
->filter('type', '=', 'User')
->execute();

foreach($results as $r) {
// This command displays all attributes in the user object. If it's under the my attribute
// then it's pulled by "my->attributeName." Comment this out if you want.
echo $r->debugHtml();

echo "My full name: [" . $r->my->fullName . "]<br>";
echo "My full name: [" . $r->my->birthdate . "]<br>";
}
?>
Attachments:

Reply to This

Thank you! much appreciated!

Reply to This

Hi Ennis!

I have attached the file bday.php, which performs a search on your network and prints out all the birthdays it finds. It is a basic script, but it should get you going in the right direction. It uses the Ning PHP API, specifically XN_Query.

Good Luck! Devin
Attachments:

Reply to This

thank you! I appreciate the help!

Reply to This

RSS

Documentation & Tips

© 2008   Created by Ning Developer Admin

Badges  |  Report an Issue  |  Privacy  |  Terms of Service