TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,055
  • Total Topics: 21,337
  • Online today: 572
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 141
  • Total: 141

PHP & SQL basic help please ?

Started by fenris_w0lf, January 23, 2006, 10:37:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fenris_w0lf

Hi,

I'm fairly new to TinyPortal and PHP. I do know my way around SQL tho.

What I'm looking for is some basic guidelines on how to fetch data from the smf tables and present them in blocks or something.

Example:
Adding a block with a link to a php file that will present the results from a select on the members table. When the users press this link - they should be taken to a page that looks much like the main home portal page, only with the memberslist in the centre (ie retain the themes etc automatically)

I would assume that I'd code some php, save it on the "root" of my forum, then add a link to the php using the "Edit Blocks" thing ? Do I have to add a "action" to do something like this ??

I did search around to try and find examples of this. If my search is bad I appologize and ask if someone could paste theyre finds.

Thanks!

Rasyr

Actually, TinyPortal allows you to create PHP Articles through the TPAdmin section.

So all you would really need to do is to code your PHP and save it in a PHP Article, and then you can actually use the Menu Manager to put it in a Menu block on the side.

The article will then load automatically where you are wanting it to load. Once Bloc releases the next version of TP, you will also be able to control other display features as well (such as whether or not the menu blocks appear or if the author or date/time of the article is needed to be displayed, etc...


fenris_w0lf

Hey thanks Rasyr,

but wouldnt the memberslist actually be displayed in the block by doing it that way? I only want to link to the list so that it gets displayed in the main centre part of the page whenever they press the link (with the rest around, like menus, other blocks etc to be retained)

I hope Im making sense here, hehe.

bloc

Showing memberlist: perhaps easiest to just go to index.php?action=mlist..it will then be in the middle..add a menuitem with that link.

fenris_w0lf

Ah yes, Thanks Bloc (wow u got time to help!!!???  ;))

I know of that one...the memberlist was more of a example.

To clearify: Lets say I want a php/mysql select statement only showing member-id and email in a separate memberlist...

fenris_w0lf

Can I use "Add php article" perhaps ??

If so...can someone please show me some examples of what is needed to do a simple select from any of the smf tables and display the result ??

Rasyr

Quote from: fenris_w0lf on January 23, 2006, 11:45:58 AM
Hey thanks Rasyr,

but wouldnt the memberslist actually be displayed in the block by doing it that way? I only want to link to the list so that it gets displayed in the main centre part of the page whenever they press the link (with the rest around, like menus, other blocks etc to be retained)

I hope Im making sense here, hehe.

You apparently misunderstood what I was saying...

Follow these Steps:

1) Click on TPAdmin button
2) Click on Edit Articles link
3) Click on Add PHP-article link (in the Blue bar, if using the 1.1 RC1 default theme)
4) Enter your Code (don't forget to give it a title or something)
5) Save
6) Click on Menu Manager link
7) Click on Add Menu Item
8) Fill in a Name for the article, select Article as the Type, and in the active drop list select the article you just created, and select its position.
9) Save, and then make it active (by clicking on the green circle in the Edit column of the Menu Manager screen).

Then, so long as you have the menubox being displayed in either the left or right column, the link will show up (it is automatically made for you from the stuff you selected in the Manu Manager), and when you click on it, your PHP article will show in the center.

As an example, I recently coded a Simple Image Gallery. This required that I add code to one of the sources files (though I guess I could have done it all in the PHP file), and then I coded the display for it and followed the directions I gave above. This screenshot shows what the result looks like.

You can find the actual thread I started about it here => http://www.tinyportal.net/smf/index.php?topic=2185.0



[attachment deleted by admin]

fenris_w0lf

GREAT!!! Thanks Rasyr!! :D

Could someone please paste some examples

Quote from: fenris_w0lf on January 23, 2006, 12:40:36 PM
...can someone please show me some examples of what is needed to do a simple select from any of the smf tables and display the result ??

I bet theres quite a few of those :)

Rasyr

Read this thread --  http://www.tinyportal.net/smf/index.php?topic=1948.0 -- for the evolution of an example (where I wrote a function that made a call to the DB) to give a listing of the forums in a box on the sidebar).

The principle is the same whether you are writing something to go in a phpbox in the  sidebar or into a php article in the middle.

So, I would suggest reading the threads in this forum -- http://www.tinyportal.net/smf/index.php?board=46.0 -- as well as they will give you all sorts of ideas on how to do things.


fenris_w0lf

Great!!!

* fenris_w0lf pays Rasyr's next round !!!

:D

This website is proudly hosted on Crocweb Cloud Website Hosting.