Problem writing a mod

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
wickedpuppy
Registered User
Posts: 3
Joined: Fri Sep 23, 2005 3:57 am
Contact:

Problem writing a mod

Post by wickedpuppy »

Hi guys
i got a newbie question , I am currently writing a mod and I need to get the result from sql into 3 drop down lists on the template page. I got the sql and i got the drop down lists ... my question is how do I put the results into the lists ?? here is my template side code

// Template side - get the list of users
<table>
<!-- BEGIN user_row -->
<tr><td>{user_row.USERNAME}</td></tr>
<!-- END user_row -->
</table>

//php side - get the user names from the mysql
$sql = "SELECT username FROM phpBB_users"; //sql statement
if ( ! ( $result = $db->sql_query($sql) ) ) //if executing sql has error , throw error
{
message_die(GENERAL_ERROR, 'Error retrieving user data', '', __LINE__, __FILE__, $sql);
}

while ( $row = $db->sql_fetchrow($result) ) //get one by one and assign to $row
{
$template->assign_block_vars('user_row',array( 'USERNAME' => ($row['username']),

)
);
}

If you know the answer or where can I find more info pls help. I read the knowledge base tutorial on modding but its too simple....

regards
wickedpuppy

afterlife_69
I've Been Banned!
Posts: 630
Joined: Tue Nov 30, 2004 10:35 am

Post by afterlife_69 »

use a block and do something like this:

Code: Select all

<select size="1" name="D1">
<!-- BEGIN ddown1 -->
    <option>option</option>
<!-- END ddown1 -->
</select>
about using 3, have a field to determine what gos where then in your loop have something like this:

Code: Select all

if($row['row_dropdown'] == 1)
{
 $template->assign_block_vars('ddown1', array(
    'VAR' => $row['var'],
 ));
}
elseif
{
 // repeat with a new number
}

wickedpuppy
Registered User
Posts: 3
Joined: Fri Sep 23, 2005 3:57 am
Contact:

Post by wickedpuppy »

Hi afterlife_69 ,
Thanks for the help ... I managed to solve it. thanks!! :P

afterlife_69
I've Been Banned!
Posts: 630
Joined: Tue Nov 30, 2004 10:35 am

Post by afterlife_69 »

glad to help.

Post Reply

Return to “[2.0.x] MOD Writers Discussion”