Having tpl issue

how do i convert this

<select name="willwin" id="willwin">
    
    <?php
if ($db->numrows() > 0){
        while ($row = $db->fetch()) { ?>
        <option value=''></option>
        <option value="<?php echo $row["willwin"]; ?>"><?php echo $row["team1"]; ?></option>
        <option value="<?php echo $row["willlose"]; ?>"><?php echo $row["team2"]; ?></option>
        <?php 
}
}
?>
    </select>
    <br/><br/>
  
    <label>Tag Bettor</label>
    <select name="sub_cat" id="sub_cat"></select>    

to look like this

$TPL_team_list = '<select name="willwin" class="form-control">' . "\n";
        while ($row = $db->fetch())
        {
            $TPL_team_list .= "\t" . '
            <option value="' . $row[''] . '" ' . $selected . '>' . $row[''] . '</option>
            <option value="' . $row['team1'] . '" ' . $selected . '>' . $row['team1'] . '</option>
            <option value="' . $row['team2'] . '" ' . $selected . '>' . $row['team2'] . '</option>
            ' . "\n";
        }
        
        $TPL_team_list .= '</select>' . "\n";

{
    $template->assign_block_vars('tag_bidder', array(
    'TEAM' => $TPL_team_list,

            ));
    $i++;
}


i cant intergrate the above form (doesnt respond when place directly) in tpl unless converted thanks.

It seems to me that the only difference is that the second one builds up a string variable called $TPL_team_list and assigns it to a template, whereas the first one just outputs the html directly. The only real difference in the content is the column names in the options.

Which particular part are you having trouble with? What happens if you just put the appropriate column names in the second version and use that?

yeah $TPL_team_list does get assigns to a template was trying to see if i can do the same with the first code so it can connect to the template

Well, you can. Just substitute the correct column names from the first code into the second, and tweak it until it works.

yeah i wanna try that again n see wat happens

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.