Populate field from a database -

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Populate field from a database -

Postby Fenice » Fri Apr 08, 2005 4:23 am

Hello all!

I have Coranto + FakeSql and CustomFields installed on a private universitary network. I am developing a way to do the following:

1) When a user post a news, he can select to which movies already in the mysql database the article is related. I would like to let them do so by selecting one or more movies from a list populated with movie titles in the movies table in the database. How can I do this?
2) Once the news has been posted, I would like to execute a separate php script to update my movies mysql table's "last updated" field with the date the news was posted. I would do this through Coranto, but I am no good in perl. So I prefer to execute a separate php script on my server and pass it the game id and the new date (updatemovietable.php?gameid=20&date=2004-06-05). How can I do this?

Thanks again for your suggestion.
Fenice
 
Posts: 16
Joined: Mon Sep 01, 2003 3:43 am

Re: Populate field from a database -

Postby Parahead » Fri Apr 08, 2005 6:17 am

Fenice wrote:1) When a user post a news, he can select to which movies already in the mysql database the article is related. I would like to let them do so by selecting one or more movies from a list populated with movie titles in the movies table in the database. How can I do this?
Two options, either you extend the CustomFields addon to create a new field, "DropDown from DB" or something. If you know Perl you could probably use the info allready in CustomFields and FakeSQL to accomplish this, but since you don´t I think this is to much hazzle. The other scenario (since you know PHP) is that you create a PHP script that fetches the content from the movie table and create a file instead, then you use the "DropDown From File"-field which is available in CustomFields. Read more in the addon how the file should be formatted.

Fenice wrote:2) Once the news has been posted, I would like to execute a separate php script to update my movies mysql table's "last updated" field with the date the news was posted. I would do this through Coranto, but I am no good in perl. So I prefer to execute a separate php script on my server and pass it the game id and the new date (updatemovietable.php?gameid=20&date=2004-06-05). How can I do this?
I would say that using the LWP::Simple module would be a good idea, with that you can execute a URL. Do a search for LWP in the forum and you will end up with some threads. A very simple example of how to use it would be:
Code: Select all
use LWP::Simple;
my $result = get("http://www.domain.com/updatemovietable.php?gameid=20&date=2004-06-05");
The hook SaveNews_2 in crcore.pl would be a good place to use for the call I think.
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby bozoka45 » Sat Apr 09, 2005 3:10 am

Are all the movies in your Coranto database as well as the SQL database? You could create another Coranto profile to create a separate file listing nothing but the movie titles, and then use CustomFields addon like Parahead said to use the "drop down options from file" mode.
User avatar
bozoka45
 
Posts: 1159
Joined: Sun Mar 23, 2003 8:38 pm
Location: New Orleans


Return to Customization

Who is online

Users browsing this forum: No registered users and 1 guest

cron