Darkwoods Posted July 9, 2011 Share Posted July 9, 2011 Hello I got an jQuery tabs and every tab got ID "fragment-1", "fragment-2" and so on now if want to tell PHP to use fragment-2 if fragment-1 is taken how do I do that? Thanks <div id="fragment-1" class="ui-tabs-panel"> <img src="assets/img/image1.jpg" title="" alt="" /> <div class="info" > <h1><?php echo $row['pr_title']; ?></h1> <p>blabla..</p> </div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/241491-help-with-if-statements/ Share on other sites More sharing options...
gizmola Posted July 9, 2011 Share Posted July 9, 2011 I'm guessing what you mean is, that you have something that drives how many tabs you need. If so, you should make a function that outputs the tab code, and generates the id based on a counter in the loop. Inside that function the div would be something like: function makeTab($id, $img, $h1, $para) { $out = ' return $out; } } Quote Link to comment https://forums.phpfreaks.com/topic/241491-help-with-if-statements/#findComment-1240490 Share on other sites More sharing options...
Darkwoods Posted July 9, 2011 Author Share Posted July 9, 2011 I'm guessing what you mean is, that you have something that drives how many tabs you need. If so, you should make a function that outputs the tab code, and generates the id based on a counter in the loop. Inside that function the div would be something like: function makeTab($id, $img, $h1, $para) { $out = '<div id="fragment-' . $id . '" class="ui-tabs-panel"> <img src="assets/img/' . $img . '" title="" // etc return $out; } Hey thanks for your reply but this wont solve the problem the jQuery tabs im using is for news posts so the fragment tabs have to be the same 1,2,3,4 it wont work with id. is there a way to tell the mysql to echo the latest second or third or forth post? this way I can echo it in every fragment.. Quote Link to comment https://forums.phpfreaks.com/topic/241491-help-with-if-statements/#findComment-1240512 Share on other sites More sharing options...
jcbones Posted July 9, 2011 Share Posted July 9, 2011 I'm guessing what you mean is, that you have something that drives how many tabs you need. If so, you should make a function that outputs the tab code, and generates the id based on a counter in the loop. Inside that function the div would be something like: function makeTab($id, $img, $h1, $para) { $out = '<div id="fragment-' . $id . '" class="ui-tabs-panel"> <img src="assets/img/' . $img . '" title="" // etc return $out; } Hey thanks for your reply but this wont solve the problem the jQuery tabs im using is for news posts so the fragment tabs have to be the same 1,2,3,4 it wont work with id. is there a way to tell the mysql to echo the latest second or third or forth post? this way I can echo it in every fragment.. That is what he gave you. Since you haven't posted any code, he gave you arbitrary code. IN that you will have to fit it to your code. It will not work as a drop in. If you post code, we could give better responses. Quote Link to comment https://forums.phpfreaks.com/topic/241491-help-with-if-statements/#findComment-1240540 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.