lucky3809 Posted December 30, 2011 Share Posted December 30, 2011 Ok I have been trying, but can't seem to get this to work correctly... First of all I am using the hide/show script from http://www.dynamicdrive.com/dynamicindex17/switchcontent2.htm demo 2.... I am using it in php but seems to not work effectively after a "while statement".... I want it to hide all names,id tables when clicked, however it seems to only want to hide one id (the one at the top of the list) instead of all ids,names in the tables... such as for instance... I have.... $nm=$db->query("SELECT id,username FROM users_s WHERE id=$name ORDER BY id ASC")or die(mysql_error()); echo '<span id="faqtable1-title" class="iconspan"></span> <table style="margin: 0 auto 0 auto; border: solid #292929 0px; width: 90%;"> <tr class="he"> <td>ID</td> <td style="width: 125px;">Name</td></tr>'; while($users=$db->fetch_row($nm)) { $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec"; echo '<tr style="background-color: '.$bgcolor .'"> <div id="faqtable1" class="icongroup"> <td>'.$users['id'].'</td> <td>'.$users['username'].'</td><div></tr></table>'; } echo <<<EOF <script type="text/javascript"> var faqtable=new switchicon("icongroup", "div") //Limit scanning of switch contents to just "div" elements faqtable.setHeader('[Hide]', '[show]') //Set header HTML faqtable.collapsePrevious(false) //Allow more than 1 content to be open simultanously faqtable.setPersist(true, 7) //Enable persistence to remember last switch content states for 7 days faqtable.init() </script> EOF; It's only hiding the first ID in the first td, and not both name and id and all info in that whole table, like it should, or how i want it too lol. Hopefully there is someone out there that can help me or direct me to a website that shows how it is done. Quote Link to comment Share on other sites More sharing options...
mixmaster Posted December 30, 2011 Share Posted December 30, 2011 (edited) replace while($users=$db->fetch_row($nm)) { $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec"; echo '<tr style="background-color: '.$bgcolor .'"> <div id="faqtable1" class="icongroup"> <td>'.$users['id'].'</td> <td>'.$users['username'].'</td><div></tr></table>'; with while($users=$db->fetch_row($nm)) { $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec"; echo '<tr style="background-color: '.$bgcolor .'"> <div id="faqtable1" class="icongroup"> <td>'.$users['id'].'</td> <td>'.$users['username'].'</td><tr>'; } print '<div></tr></table>'; edited Edited December 31, 2011 by illusions removed broken coding Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted December 30, 2011 Author Share Posted December 30, 2011 (edited) that is weird your getting font stuff on my end it does not show font stuff but on what you posted...forum must be acting up again for certain people... Edited December 30, 2011 by lucky3809 Quote Link to comment Share on other sites More sharing options...
Uridium Posted December 31, 2011 Share Posted December 31, 2011 (edited) Edited your post Mixmaster Edited December 31, 2011 by illusions Quote Link to comment Share on other sites More sharing options...
mixmaster Posted December 31, 2011 Share Posted December 31, 2011 Thanks illusions Quote Link to comment Share on other sites More sharing options...
Djkanna Posted December 31, 2011 Share Posted December 31, 2011 while($users=$db->fetch_row($nm)) { $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec"; echo '<tr style="background-color: '.$bgcolor .'"> <div id="faqtable1" class="icongroup"> <td>'.$users['id'].'</td> <td>'.$users['username'].'</td><tr>'; } print '<div></tr></table>'; Well that's not going to work, you'll end up with several nested div elements and no closing divs. Generally speaking an ID should only appear once within a page, this is why you'll only modify the first element with the id and not the rest of the elements with the ID. As far as I am aware (someone may be able to confirm/correct this) things like getElementById(); (which I believe you'd be using somewhere within your js) will only return the first it finds. Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted December 31, 2011 Author Share Posted December 31, 2011 Thanks everyone who tried to help. I figured it out had to do the research from facebook pagnation http://youhack.me/2010/05/14/an-alternative-to-pagination-facebook-and-twitter-style/ which uses php... Had to put this before the query <?php then after the while statement add a few vars, then end the php tag, then do something along the lines such as <div id="faqtable1" class="icongroup"> <td> <?php echo $blah; ?> </td> </div> for it to work... Dunno why it needed to be complicated to work with php but it seemed so. Quote Link to comment 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.