1. ## eval

Hi,

I hope someone can help.

I am using the following code to select the ID of a moderator from the table qb_mods and then get their username from qb_members. This works fine and prints all the moderators correctly, even if there is more than one.

PHP Code:
$msql mysql_query("SELECT m.MemID, mem.UserName FROM qb_mods m, qb_members mem WHERE Forum = '$forums[FID]' AND m.MemID = mem.MID") or die(mysql_error());

$num_rows mysql_num_rows($msql);
if (
$num_rows == 0) { echo "&nbsp;"; } else { while ($mods mysql_fetch_array($msql) ) { echo "<a href=\"profile.php?user=$mods[UserName]\">$mods[UserName]</a> \n"; } echo " </font></td>\n"; echo " </tr>\n"; Now the problem, I want to use a template system using eval. How can I change this code so that I can replace a variable ($moderators) in the template with all of the moderators, even if there is more than one ?

Sean

2. You can use

PHP Code:
while ( $mods mysql_fetch_array($msql) ) {

$tmp .= "<a href=\"profile.php?user=$mods[UserName]\">$mods[UserName]</a> \n"; } str_replace($moderators$tmp$templatestring);

Is that what you are after?

3. Wow, thanks for the quick reply.

Ok, I tried that but I get the following error : Warning: The length of the needle must not be 0 in c:\apache\htdocs\qboard\in2.php on line 56

This might have something to do with how I am using your code. Right, what I did was open the template like this :

PHP Code:
$m template("$tpath/forumsbar.htm");
This implodes the file. I then used your code and replaced the $moderators variable like this : PHP Code: str_replace($moderators$tmp$m);
Then I used eval to replace the rest of the template variables :

PHP Code:
eval("echo stripslashes(\"\$m\");");
Any thoughts ?

Sean

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•