HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Block that looks at an sql table.

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#24040 (In Topic #5763)
Avatar

Community saint

Kind of like this code on setting up a random link using bfarber's link system.
This is not my code and was written by -Calypso- over at http://invisiontweaks.com.
This Tutorial Is Based Off Of bfarber's Link System Mod.

Open: sources/classes/class_display.php

Find:

Code

      $this->ipsclass->skin['_wrapper'] = str_replace( "<% CHARSET %>"      , $this->ipsclass->vars['gb_char_set'], $this->ipsclass->skin['_wrapper']);

Add Below:

Code

            //-----------------------------------------
            // Random Links 1.0
            //-----------------------------------------

            {
            $this->ipsclass->DB->query("SELECT link, href, mem_name, mem_id FROM ibf_links ORDER BY RAND() LIMIT 1");

             $this->ipsclass->DB->simple_exec();

             $r = $this->ipsclass->DB->fetch_row();


            $this->ipsclass->skin['_wrapper'] = str_replace( "<!--LINKS-->" , $this->ipsclass->compiled_templates['skin_global']->random_links($r), $this->ipsclass->skin['_wrapper']);
            }


Save & Upload class_display.php

Go To: AdminCP > Look & Feel > SelectSkin > Edit Template HTML > All Global HTML

Add Template Bit

New Template Bit Name: random_links
New Template Bit Incoming Data Variables: $r=""

Click "Continue"

In The Open HTML Block, Paste The Following:

Code

<br />
<table align='center' width='100%' class='row3' cellspacing='0' cellpadding='3'>
   <tr>
    <td>
<div style="text-align: left;" id="div_example1"><b>Random Link:&nbsp;&nbsp;<a href="{$r['href']}">{$r['link']}</a></b><br /><b>Submitted By:</b>&nbsp;&nbsp;<a href="{ipb.script_url}showuser={$r['mem_id']}">{$r['mem_name']}</a></div>
</td>
   </tr>
  </table>

Save Template Bit

Go To: AdminCP > Look & Feel > SelectSkin > Edit Board Header & Footer Wrapper

Find:

Code

<% BOARD %>

Add Below:

Code

<!--LINKS-->

Save Wrapper

All Done!
Enjoy :thumbsup:


Last edit: by Philip

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24056
Avatar

Community saint

I take it I would have to create some kind of mini block in the customer blocks folder.
Or would using the html tag work?

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24075
Avatar

Community saint

I take it I am going to need to learn php my sql fetch for this.

I did do a google search and found this.
displaying data from an sql table - Google Search but nothing helps so far.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24080
Avatar

Community saint

Open up sources/lib/func_boardstats.php

Find -

Code

    $stats_html .= $this->ipsclass->compiled_templates['skin_boards']->ShowStats($this->ipsclass->lang['total_word_string']);

Replace with -

Code


$stats=array();
          $this->ipsclass->DB->simple_construct(array('select' => 'id', 'from' => 'articles'));
            $this->ipsclass->DB->simple_exec();
            $stats['numarticles'] = $this->ipsclass->DB->get_num_rows();

            $stats_html .= $this->ipsclass->compiled_templates['skin_boards']->ShowStats($this->ipsclass->lang['total_word_string'], $stats);

Save & Upload. Now go to ACP –> Look & Feel –> Edit Template HTML –> Board Index –> ShowStats.

Add $stats="" onto the end of the data variable list. You can now use {$stats['numarticles']} in the template bit to display the number of articles.

Here is another example it that helps.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24083
Avatar

Community saint

It can not be that hard.
Maybe you should ingnore the examples and concentrate on the subject.
which is Using php code to display any thing I want from the sql.
Weather it be the amount of rows in a table or the contect of a table, row.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24092
Avatar

That's a very dangerous thing to have on a website unless it's totally secure. I think it would be better if you just used something like phpMyAdmin. :nod:

Back to the top
 
Posted
Rating:
#24093
Avatar

Community saint

That would take forever.
I would then end up needing to change it every time some thing was changed and or added.
It can not be that dangerous as I bet there is one of these creating your name  or showing you how many posts you have or showing the post it self.  :'(  :(

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24101
Avatar

Community saint

For know tell I learn how to do this I will add this to the stats to get the results that I want.
"We have 500 games in the arcade and 7 links in the links system"
If games are added I will just change that text manually.  There are a few other things I want to add but they will take up a lot of time in counting them in the phpmyadmin like you told me to do.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24121
Avatar

So you want a block which will display various statistics about things in the database?

Back to the top
 
Posted
Rating:
#24138
Avatar

Community saint

yes and also display data from a post in the database.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
Posted
Rating:
#24172
Avatar

An example of a small block which does a database query would be the main_top_downloads block. You could look at the code if you wanted (it's in /sources/blocks/main_top_downloads.php).

Back to the top
 
Posted
Rating:
#24182
Avatar

Community saint

I actually thought about looking at the code for showing posts.

I run http://otakuplayground.com and am hopping to make themes and other things for ocportal even though I no longer use it for otakuplayground.com I still love it and feel it could go far with the right help. It needs themes and needs people to advertise for it.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: