I am using another database with CMSMS. (Technically I have one datebase with many non-CMSMS tables, as my ISP will only let me have one database).
The following user defined tag will give the information on this page (main section):
http://www.torvund.net/guitar/index.php?page=artists
Tag:
$start_offset = $params['start'] ? $params['start'] : "0";
$num = $params['num'] ? $params['num'] : "50";
$artists = @mysql_query( 'SELECT * FROM person WHERE LastName LIKE "' . $params['letter'] . '%" ORDER BY LastName, FirstName LIMIT ' . $start_offset . ', ' . $num );
$num_rows = mysql_num_rows( $artists );
echo 'fant ' . $num_rows . ' artister
';
while ($row = mysql_fetch_array($artists)) {
echo '
' . $row['LastName'] . ', ' . $row['FirstName'] . ' Books
DVD
RecordingsCDsEquipment';
/* for instance Artist, The */
}
echo '';
echo '';
if ( (int) $start_offset - (int) $num >= 0 ) {
echo ' ';
}
echo ' ';
echo ' ';
____
As you can see, it creates URLs listed on the site where this tag is included. By clicking on one of the links you will open a new page where a tag with this content is included (one example of the result - if you choose The Beatles, can be found at
http://www.torvund.net/guitar/index.php ... s&aid=1132 ):
$artist_id = mysql_real_escape_string($params['aid']);
// Hent artistinfo
$artist = @mysql_query("SELECT * FROM person WHERE PersonID=" . $artist_id . ";");
$row = mysql_fetch_array($artist);
$firstname = $row['FirstName'];
$lastname = $row['LastName'];
$memo = $row['Memo'];
echo '' . $row['FirstName'] . ' ' . $row['LastName'] .' - books';
echo '
Books -
DVD -
Recordings - CDs - Equipment ';
echo '' . $row['Memo'] . '';
//New Books
echo 'New books (or books with updated information)';
if ( isset( $params['frmid'] )){
$newbooks = @mysql_query('SELECT * FROM linkpersonbook, book WHERE PersonID= ' .$params['aid'] . ' AND linkpersonbook.BookID=book.BookID AND
Format="' . $params['frmid'] . '" AND oppdatert >= ' . strtotime("-3 months") . ' ORDER BY Oppdatert DESC;');}
else {$newbooks = @mysql_query('SELECT * FROM linkpersonbook, book WHERE PersonID= ' .$params['aid'] . ' AND linkpersonbook.BookID=book.BookID AND oppdatert >= ' . strtotime("-3 months") . ' ORDER BY Oppdatert DESC;');}
while ($row = mysql_fetch_array($newbooks)) {
echo '
More >>
' . $row['BookTitle'] . '
' . $row['Subtitle'] . '
RefNr: ' . $row['RefNr'] . '
Order From:
';
if ($row['SMPlus']) {
echo 'SheetmusicPlus';
}
if ($row['MR']) {
echo 'MusicRoom';
}
if ($row['ASIN']) {
echo 'Amazon UK
Amazon US';
}
if ($row['ISBN']) {
echo'
';}
echo '
';
}
/* $books = @mysql_query('SELECT * FROM linkpersonbook AS lp, book AS b WHERE lp.PersonID="' . $artist_id . '" AND linkpersonbook.BookID=book.BookID;'); */
// Hent alle bøker av/om artist, sortert etter kategori, så alfabetisk
if ( isset( $params['frmid'] )){
$books = @mysql_query('
SELECT b.*, r.*, p.FirstName
FROM book AS b, person AS p, role AS r, linkpersonbook as lp
WHERE lp.PersonID=' .$params['aid'] . ' AND
p.PersonID=lp.PersonID AND
r.RoleID=lp.RoleID AND
b.BookID=lp.BookID AND
Format="' . $params['frmid'] . '"
ORDER BY Sort1, b.BookTitle;');}
else {$books = @mysql_query('
SELECT b.*, r.*, p.FirstName
FROM book AS b, person AS p, role AS r, linkpersonbook as lp
WHERE lp.PersonID=' .$params['aid'] . ' AND
p.PersonID=lp.PersonID AND
r.RoleID=lp.RoleID AND
b.BookID=lp.BookID
ORDER BY Sort1, b.BookTitle;');}
echo '';
$old_role = "";
while ( $book = mysql_fetch_array($books) ) {
$role = $book['Role'];
// Print rolle overskrift, hvis det er en ny kategori
if ($role != $old_role) {
echo 'Books ' . $role .' ' . $firstname . ' ' . $lastname . '';
}
// Print info om bok
echo '
More >>
';
echo '
' . $book['BookTitle'] . '' . $book['Subtitle'] . '
Level: ' . $row['GLevel'] . ', ' . $row['Pages'] . ' pages
RefNr: ' . $book['RefNr'] . '
Order From:
';
if ($book['SMPlus']) {
echo 'SheetmusicPlus';
}
if ($book['MR']) {
echo 'MusicRoom';
}
if ($book['ASIN']) {
echo 'Amazon UK
Amazon US';
}
if ($book['ISBN']) {
echo'
';
}
echo '
';
// Backup forrige boks rolle
$old_role = $role;
}
echo "";
-----
The links in the right column on this page is also taken from a non-CMSMS table in the database, and the navigation to the left is used to narrow down the result by adding another paramter.
As I am technically using the same database, I do not have to worry about opening and closing the database. But apart from that, I think that it shows one example on how to extract information from another database and include it on CMSMS pages.