1
yellowchimp
is it simple to make a page, stored within xoops, search a database??

FIrst of all - sorry for double posting this - but I accidentally posted in the wrong forum!! So sorry for that.


Will it be straightforward to make a page in php (don't actually know any php yet!) (putting a database on the server with a DSN connection?) that will ask questions of the databse and return results.
I would want the php page to sit within my XOOPS theme and template and the returned results to be wrapped in my XOOPS webpage.
Can anybody tell me if this will be as straightforward as if it wasn't being wrapped in a content management system. Any pointers to tutorials or any tips would be hugely appreciated.

Many thanks

Yellowchimp

2
dreamgear
Re: is it simple to make a page, stored within xoops, search a database??
  • 2004/9/21 13:37

  • dreamgear

  • Friend of XOOPS

  • Posts: 78

  • Since: 2002/7/18


I've written a custom module that takes a table that is stored within the XOOPS database but which has no admin interface, and formats it.

I update it by downloading a .csv file from another site and then using MS access push it back to the server via the mysql-odbc driver.

The module is fairly simple.

The index.php just does this:

require('header.php');

include_once 
XOOPS_ROOT_PATH."/modules/bslist/class/class.bslist.php";

// We must always set our main template before including the header
$xoopsOption['template_main'] = 'bslist_simple.html';

$bs_array BsList::get_bs();
$bs_count count($bs_array);

// Include the page header
require(XOOPS_ROOT_PATH.'/header.php');

$xoopsTpl->assign('bs_count'$bs_count);
$xoopsTpl->assign('bs_array'$bs_array);

// Include the page footer
require(XOOPS_ROOT_PATH.'/footer.php');
?>


The two class files look like this:

::::::::::::::
class/class.bslist.php
::::::::::::::

include_once "class.bsmember.php";

class 
BsList extends BsMember
{
    function 
get_bs($limit=0$start=0)
    {
        
$db =& Database::getInstance();
        
$ret = array();
        
$sql "SELECT * FROM ".$db->prefix("bslist");
        
$sql .= " ORDER BY LastName";
        
$result $db->query($sql,intval($limit),intval($start));
        while ( 
$myrow $db->fetchArray($result) ) {
            
$ret[] = new BsMember($myrow);
        }
        return 
$ret;
    }
}
?>
::::::::::::::
class/class.bsmember.php
::::::::::::::

class BsMember
{
    var 
$MemberNumber;
    var 
$LastName;
    var 
$FirstName;
    var 
$Nickname;
    var 
$SpouseFirst;
    var 
$Address1;
    var 
$Address2;
    var 
$Address3;
    var 
$City;
    var 
$State;
    var 
$ZipPC;
    var 
$Country;
    var 
$Email;
    var 
$Type;
    var 
$SocietyExpiration;
    var 
$ChapterExpiration;
    var 
$HomePhone;
    var 
$WorkPhone;
    var 
$Fax;
    var 
$YearsOfService;
    var 
$BirthDate;
    var 
$MenOfNote;

    function 
BsMember ($ary)
    {
        
$this->LastName $ary["LastName"];
        
$this->FirstName $ary["FirstName"];
        
$this->HomePhone $ary["HomePhone"];
        
$this->WorkPhone $ary["WorkPhone"];
        
$this->Email $ary["Email"];

        if (
$this->HomePhone == "0--0"$this->HomePhone "";
        if (
$this->WorkPhone == "0--0"$this->WorkPhone "";
    }
}


and the template looks like this:

<style>
.
bslist td padding2px 1ex 2px 1ex; }
style>
<
table class="bslist" llspacing="0" cellpadding="0">
<
tr class="head">
<
td>Nametd>
<
td>Home Phonetd>
<
td>Work Phonetd>
<
td>Emailtd>
tr>
<{
section name=bs_mem loop=$bs_array}>
<
tr class='<{cycle values="even,odd"}>'>
<
td><{$bs_array[bs_mem]->LastName}>, <{$bs_array[bs_mem]->FirstName}>td>
<
td><{$bs_array[bs_mem]->HomePhone}>td>
<
td><{$bs_array[bs_mem]->WorkPhone}>td>
<{
assign var="email2" value=$bs_array[bs_mem]->Email}>
<
td><{if $email2}><{mailto address=$email2 encode="javascript"}><{/if}>td>
tr>
<{/
section}>
table>



Login

Who's Online

176 user(s) are online (130 user(s) are browsing Support Forums)


Members: 0


Guests: 176


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits