Why the data-target is not working in bootstrap if I use php to generate the id?

I am using bootstrap to list some of the speakers details. Let say for example my code is the following:

    <?php

        global $wpdb;
        $result = $wpdb->get_results("SELECT * FROM  `Invited_Speakers_auto`   ORDER BY `Last_Name` ASC;");
        foreach ( $result as $print)   { ?>


<div class="DemoBS2" > 


  <!-- Toogle Buttons -->
    <button type="button" class="btn btn-warning" id="toggle-btn"
  data-toggle="collapse" data-target="#<?php echo $print->Unique_Id;?>" >Click to Toogle</button>
 
    <div id="<?php echo $print->Unique_Id;?>" class="collapse in">
      <p>If you don't like something, <b>change it</b>. 
	  If you can't change it, change your <b>attitude</b>.</p></div>
  

</div>


 <?php } ?>

It gives my only the toggle buttons but its not working as such.

What is the mistake. click here to see the error.

thanks in advance.

Edit:

When I run the above query and php code, I get the following for the first entry.

<button type="button" class="btn btn-warning" id="toggle-btn" data-toggle="collapse" data-target="#17ICLAA501
">Click to Toogle</button>
 
    <div id="17ICLAA501
" class="collapse in">
      <p>If you don't like something, <b>change it</b>. 
	  If you can't change it, change your <b>attitude</b>.</p></div>
  

</div>

I dont know, why the space is coming after the $Unique_Id in both data-target and id.

I could convince myself that if I remove the whitespaces and newlines. I will be through…

How to acheive this?

Kindly give me a complete solution since, I am newbie to php.

That seems to be a carriage-return rather than spaces, is it possible that is screwing up the id and therefore stopping the CSS working? Did you import the data from somewhere that has resulted in the id containing a carriage-return or line feed character that should have been stripped out?

I’m happy to help you find a solution, but not to just do it for you, even if I could.

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