skyhighweb 0 Posted May 23, 2017 Report Share Posted May 23, 2017 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 Quote Link to post Share on other sites
thescientist 231 Posted May 23, 2017 Report Share Posted May 23, 2017 What part specifically do you need help with? It's not very clear from your post. Quote Link to post Share on other sites
skyhighweb 0 Posted May 23, 2017 Author Report Share Posted May 23, 2017 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 Quote Link to post Share on other sites
dsonesuk 913 Posted May 24, 2017 Report Share Posted May 24, 2017 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. Quote Link to post Share on other sites
skyhighweb 0 Posted May 25, 2017 Author Report Share Posted May 25, 2017 yeah i understand what u saying i keep trying it but doesnt burge Quote Link to post Share on other sites
dsonesuk 913 Posted May 25, 2017 Report Share Posted May 25, 2017 Again! You say you tried it, but don't provide evidence that you have done anything of the kind, which gives me/us impression that you want us to do it for you. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.