Mortier Posted October 17, 2006 Share Posted October 17, 2006 Hello people!I have just started using TemplatePower as a templating engine for my website. But I have come to the following problem: how do I apply my selectmanipulation() function?[code]<? // als $data_type == 1, moet het resultaat met een while worden opgehaald // als $data_type == 0, gebruiken we de data als array // $data_name == veldnaam // $data == array of sql query // $set is array met veldwaarden // $css is stylenaam function ManipulateSelect($data_type, $data_name, $data, $set, $css) { echo '<select name="' . $data_name . '" class="' . $css .'">'; if($data_type == 1) //while { //$data == mysql query $result = mysql_query($data); while($list_data = mysql_fetch_assoc($result)) { echo $list_data['id']; if($list_data['id'] == $set[$data_name]) { $selected[$data_name] = 'selected'; } else { $selected[$data_name] = ''; } echo '<option value="' . $list_data['id'] . '" ' . $selected[$data_name] . '>' . htmlspecialchars($list_data['name']) . '</option>'; } } else //array met foreach { foreach($data as $id => $value) { if($id == $set[$data_name]) { $selected[$data_name] = 'selected'; } else { $selected[$data_name] = ''; } echo '<option value="' . $id . '" ' . $selected[$data_name] . '>' . $value . '</option>'; } } echo '</select>'; } ?>[/code]That's my function. It works perfect without templates ( it makes the option selected which is selected according to POST or SQL. Any ways of making it compitable with my TemplatePower??Thanks for your help in advance,Alex Quote Link to comment https://forums.phpfreaks.com/topic/24236-templatepower-using-my-select-manipulation/ Share on other sites More sharing options...
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.