Location: PHPKode > scripts > BOOKS module for PostNuke > books-module-for-postnuke/modules/Books/random_book.php
<?php // $Id: random_book.php,v 1.3 2002/01/28 16:38:26 micha Exp $
// ----------------------------------------------------------------------
// BOOKS module
// Copyright (C) 2001, 2002 by IB Rahn, http://www.ib-rahn.de
// Written by Michael Schatz, hide@address.com
// get the newest version at http://www.bauphysik.com
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------

if (!eregi("modules.php", $PHP_SELF)) { die ("You can't access this file directly..."); }
if (!isset($mainfile)) { include("mainfile.php"); }

$ModName = basename( dirname( __FILE__ ) );
$modset = modules_settings_enh($ModName);
 
include("$modset[basepath]/config.php");
include("$modset[basepath]/functions.php");

/*--------------------------------------------------------------------------
 * function  RandomBook
 *--------------------------------------------------------------------------
 * purpose   select a random title and link to the url
 * input     -
 * output    -
 * changes   2001-09-21 [MS] show book, don't go directly to url
 *--------------------------------------------------------------------------*/
function RandomBook() {
    global $pntable, $modset;
    include("header.php");
    $mainlink = 1;
    menu($mainlink);
    echo "<br>";
    OpenTable();
    $result = mysql_query("select count(*) as count from $pntable[books_books]");
    $numrows = mysql_result($result,0,"count");
    if ($numrows == 1) {
        $randombkid = 1;
    } else {
        srand((double)microtime()*1000000);
        $randombkid = rand(1,$numrows);
    }
    ShowBook($randombkid);
    CloseTable();
    include("footer.php");
}

/************************************************************************/
/*  Main initialization                                                 */
/************************************************************************/
RandomBook();
?>
Return current item: BOOKS module for PostNuke