Any advice / tutorials on working with Arrays?
I need to create an array (not sure how, but I understand the concept) for members which I can then list or pull out individually according to their ID or Name or with a search query.
I found this PHP tutorial, I’m just wondering... I guess I just stick an array into a chunk with PHP and it automagically works well with MODx?
http://www.tizag.com/phpT/arrays.php
Thanks, ganeshXL. I kind of get it. Would it be possible for someone to mock up dummy code to suggest how an array might hold / display a member’s name, photo and description? Or is this something I should be asking on a PHP forum?
-
☆ A M B ☆
- 24,524 Posts
$member = array('name' => $name, 'photo' => $url, 'description' => $description);
If the values come from the database, they are OK as-is, but if they are coming in from the client (a form on a webpage) you would need to "sanitize" them to make them SQL-safe first.
Awesome! That’s definitely what I need to start! Now I just need to figure out how to put different items like images and member descriptions into the table rows retrieved by the array... er, right?
-
☆ A M B ☆
- 24,524 Posts
Right. It’s all in the database! Gotta put stuff in before you can get stuff out!
I’ve got a tutorial on writing database-management modules on my sottwell.com site.
Quote from: sottwell at Nov 07, 2007, 12:34 PM
Right. It’s all in the database! Gotta put stuff in before you can get stuff out!
I’ve got a tutorial on writing database-management modules on my sottwell.com site.
Thank you! You are a very generous person, indeed! (I accidentally stumbled over your platinum sponsorship listing just now!)
PS. Sottwell.com is giving an Install Now? message... I clicked it thinking it was a joke. Hope I didn’t screw up your install.
-
☆ A M B ☆
- 24,524 Posts
No, I’m messing around with the .htaccess and trying to get a secondary php 5 CGI install working. It’s not being cooperative, so I’m having my hosting people just switch the whole thing to php 5. I’ve only got a few domains on my server and they’re all on MODx, so it shouldn’t cause a problem. It should be working fine now.
Hi, S
Just one question on your module tutorial here:
http://www.sottwell.com/database-module.html
You’ve created two different modules, then? Database and dbManager? The tutorial starts out with dbManager and then at the end it seems to be on Database... it seems like I missed something here.
The php code for
dbManager module is "Database Management Stuff Goes Here"
but the
Database module php code is
include $modPath."/database.php"; ?
Seems weird... or, at least, I don’t understand it.
-
☆ A M B ☆
- 24,524 Posts
No, it’s the same thing, just in three stages. The three sets of downloads have the files for the corresponding article, just in case somebody wants to follow along with the articles.