I am making a module. Right now it's based off the sample module from jan304. It works fine. To the xoops_version, I added a SQL entry to create a database with columns of "cid" and "owner" and some other columns, but right now I dont care about them.
$modversion['sqlfile']['mysql'] = "sql/mysql.sql";
$modversion['tables'][0] = "charsheet_core";
I manually added entries to the table via phpadmin
which is something like:
cid =1
owner = bob
I've edited the index.php and the sample_html.html(the template) to reflect what I am trying todo
my index changes is:
$username = !empty($xoopsUser) ? $xoopsUser->getVar('uname') : $xoopsConfig['anonymous'];
$userid = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
//$sq = ".$xoopsDB->prefix("charsheet_core").";
$sq = "sql2";
$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("charsheet_core")." WHERE 'owner' = '$username' ORDER BY 'cid' ASC");
while ( $myrow = $xoopsDB->fetchArray($result) )
{
$cid=$myrow["cid"];
}
$xoopsTpl->assign('uname', $username);
$xoopsTpl->assign('theid', $userid);
$xoopsTpl->assign('charid', $cid);
$xoopsTpl->assign('sqtest', $sq);
and my sample_html chages are:
Greetings <{$uname}> and <{$theid}>
<br>hi1
<br><{$sqtest}><br>
<{$charid}>
<br><br>
hi3
Note: These are just the changes I added to the otherwise perfectly working
When I am logged in as the user 'bob',the output of the module is:
Quote:
Greetings bob and 1
hi1
sql2
hi3
So I know that I did the getting the username part right, getting the userid part right. Then assigning those values to be used in the template.
However the database part is I fudged on, I should be getting a "1" for the cid, since that row is owned by bob.
The module is updated, and I am running debugging with mysql/blocks set to on with no errors being reported.
What am I doing wrong here?