I am trying to work out these fuctions with phplib and the database module.
I have a repeat query i want to do often. I made this into a function as follows:
which works if i call it likePHP Code:function template_get2($template,$mysql_link) {
$query = "SELECT * from email WHERE name='$template'";
$result = mysql_query($query, $mysql_link);
while ( $row = mysql_fetch_array($result) ) {
$email = $row['email'];
}
return $email;
}
for example, the prints my "admin" template which is what i want.PHP Code:echo template_get2(admin,$mysql_link);
But i would really like to include this into the php-lib mysql class to make it easier. I tried this in the normal php script
which didn't work and nor did trying to add a fuction to phplib itself:PHP Code:function template_get($template) {
$query = "SELECT * from email WHERE name='$template'";
$db->query($query);
while($db->next_record()) {
$email_from_admin = $db->f("email");
return $email_from_admin;
}
}
If anyone has a few pointers on how to do this sort of thing well that would be cool![]()






Bookmarks