Jump to content

am having tpl isuue


skyhighweb
 Share

Recommended Posts

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

Link to comment
Share on other sites

18 minutes ago, thescientist said:

What part specifically do you need help with?  It's not very clear from your post.

thansk for replying i use a tpl as frontend display, but the code above the first one cant work in tpl unless convertered this is the full code below

$query = "SELECT a.id, a.team1, a.team2, b.auction, b.bidder, b.tagged, b.willwin, b.willlose FROM " . $DBPrefix . "auctions a
		LEFT JOIN " . $DBPrefix . "bids b ON (b.auction = a.id)
		WHERE a.id = :auc_id and a.id = a.id group by a.id";
		$params = array();
		$params[] = array(':auc_id', $id, 'int');
		$db->query($query, $params);
?>

<script type="text/javascript" src="js/dropdownjquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    
	$("#willwin").change(function() {
		$(this).after('<div id="loader"><img src="images/loading.gif" alt="loading subcategory" /></div>');
		$.get('loadsubcat.php?willwin=' + $(this).val(), function(data) {
			$("#sub_cat").html(data);
			$('#loader').slideUp(200, function() {
				$(this).remove();
			});
		});	
    });

});
</script>
<form name="bid">
	<label for="category">Select Winner</label>
    <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>
</form>

it only works inside php files and not tpl

below is an example of a php with tpl connector

 

// team
		$query = "SELECT a.id, a.team1, a.team2, b.auction, b.bidder, b.tagged, b.willwin, b.willlose FROM " . $DBPrefix . "auctions a
		LEFT JOIN " . $DBPrefix . "bids b ON (b.auction = a.id)
		WHERE a.id = :auc_id and a.id = a.id group by a.id";
		$params = array();
		$params[] = array(':auc_id', $id, 'int');
		$db->query($query, $params);

		$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++;
}

hope u understand what am trying to accomplish

Link to comment
Share on other sites

You have to give it a specific block name (as used with 'tag_bidder'), and  specific array key name (as used with 'TEAM'), then concatenate the outputted html (select, options etc), as a string to a specific variable (as used with '$TPL_team_list'), this is the array value that will be assigned to key of 'TEAM'.

In your template file you should have something similar to

<div>{tag_bidder.TEAM}</div>

Where it will insert the stored code from blockname.keyname (tag_bidder.TEAM).

So ALL html has to be assign as a string to variable to store in array.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...