Gossamer Forum
Home : Products : Gossamer Links : Discussions :

accessing data from database

Quote Reply
accessing data from database
Hi -

I want to be able to access the contents of a certain column in the links table via SSI (or actually via php).

So i need to know which CGI to call to get for example, the title, of a certain ID when called from a static html page that includes some php (or ssi) code

Is it page.cgi? Or is there a summary somewhere of what each of these cgi scripts does? I can't seem to find it anywhere.

thanks
Quote Reply
Re: [JonathanKincaid] accessing data from database In reply to
Hi,

Sorry, not sure I understand what you're trying to do?

Did you want to use page.cgi to grab a value, or a "global" to use inside GLinks?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] accessing data from database In reply to
Hi Andy

I want to access data that is stored in the Links SQL database from outside of a links template. Specifically, i have an html page with php code in it (or you could do the same with an ssi) and i need to know which cgi file i execute to get data from the databse and put it into a variable so that I can use it on the html page.

If you look at my response to this thread, http://www.gossamer-threads.com/...orum.cgi?post=285466 maybe that will give you a better idea.

Another similar application that I have been considering would be to put a 'link of the day' on the home page. I would want to query the database, get the title, the description and a link to the detailed page and then insert it into my home page html using php.

Of course I have my server configured to parse html pages for php commands.

thanks
Quote Reply
Re: [JonathanKincaid] accessing data from database In reply to
Hi,

Why not use a global?

1) Create a global, called "new_link". Something like;

Code:
sub {
my $max = $DB->table('CatLinks')->select( ['MAX(ID)'] )->fetchrow;
my $link = $DB->table('Links')->get($max);
return Links::SiteHTML::display('link',$link);
}

2) Then, make a new page (something like front_new.html) via the Build > User Templates method. Then, add this (or similar) to it;

Code:
<%new_link%>

3) Try calling it with: http://www.yoursite.com/cgi-bin/page.cgi?p=front_new

4) IF the above works ok, you should be able to include it in your PHP pages via a "virtual" command, exaplined here: http://uk2.php.net/function.virtual

Hope that helps Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] accessing data from database In reply to
 
Why not use a global?

1) Create a global, called "new_link". Something like;
sub {
my $max = $DB->table('CatLinks')->select( ['MAX(ID)'] )->fetchrow;
my $link = $DB->table('Links')->get($max);
return Links::SiteHTML::display('link',$link);
}[/reply]

Hi Andy -

This looks promising and also better than my php solution because it will be static...

But I'm not familiar with this syntax.

using the above subroutine, $max will be an array of all the links in the database? and $link will be what? I don't get it? If i have the basic links database with a new column called "caption" that contains the text for a photo caption, how do i make a subroutine "photo_caption" that just gives me the text caption for a photo??

I will look into this virtual command as well, but I ssuppose that if I create a new tempate and I want static pages for this, I can just link to that page and then build the pages?
Quote Reply
Re: [Andy] accessing data from database In reply to
Quote:

3) Try calling it with: http://www.yoursite.com/cgi-bin/page.cgi?p=front_new

4) IF the above works ok, you should be able to include it in your PHP pages via a "virtual" command, exaplined here: http://uk2.php.net/function.virtual


So that virtual command works like a php 'include' except for the command will execute the cgi and display the results in the php page right?

That would work well for my home page. This sounds like a good solution, i just need to know more about what that subroutine is actually doing (since i am a PERL semi-illiterate)!

thanks again