- Readme First! - Read and follow the rules, otherwise your posts will be closed
There are currently, 45 guest(s) and 0 member(s) that are online. You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - How do I pull data from a table into a module? [ ]
Author
Message
jimmyjimjim
Lieutenant
Joined: Jan 23, 2003
Posts: 258
Location: USA
Posted:
Thu Feb 06, 2003 7:49 pm
I built a table called 'nuke_demo'.
It has 2 columns:
demo1 text not null
demo2 text not null
how can I get the text from the table into my new module?
I tried this...
function demo() {
global $demo1, $demo2;
if ($demo1 != "") {
echo "$demo1<br>\n";
}
if ($demo2 != "") {
echo "$demo2<br>\n";
}
}
It obviously didn't work. I'm using php-nuke 6.5b6 at my test site.
Any suggestions?
Zhen-Xjell
Nuke Cops Founder
Joined: Nov 14, 2002
Posts: 5939
Posted:
Thu Feb 06, 2003 7:51 pm
You have to call it via a mysql select query:
select * from demo;
And assign it to variables that you can use.
_________________ Paul Laudanski, Microsoft MVP Windows-Security
CastleCops: [de ] [en ] [wiki ]
jimmyjimjim
Lieutenant
Joined: Jan 23, 2003
Posts: 258
Location: USA
Posted:
Thu Feb 06, 2003 7:58 pm
Sorry, I'm a little lost.
I understand that:
$sql = "SELECT * FROM demo";
but what do you mean by assign variables that I can use?
Zhen-Xjell
Nuke Cops Founder
Joined: Nov 14, 2002
Posts: 5939
Posted:
Thu Feb 06, 2003 8:06 pm
Example from index.php:
$sql = "SELECT * FROM ".$prefix."_referer";
$result = $db->sql_query($sql);
$numrows = $db->sql_numrows($result);
if($numrows>=$httprefmax) {
$sql = "DELETE FROM from ".$prefix."_referer";
$result = $db->sql_query($sql);
}
_________________ Paul Laudanski, Microsoft MVP Windows-Security
CastleCops: [de ] [en ] [wiki ]
chatserv
General
Joined: Jan 12, 2003
Posts: 3128
Location: Puerto Rico
Posted:
Thu Feb 06, 2003 8:16 pm
More or less, it'd come up to something like:
Code:
function demo() {
$sql = "SELECT demo1, demo2 FROM ".$prefix."_demo";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$demo_one = $row[demo1];
$demo_two = $row[demo2];
if ($demo_one != "") {
echo "$demo_one<br>\n";
}
if ($demo_two != "") {
echo "$demo_two<br>\n";
}
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum