Jump to content

Recommended Posts

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.