dgnzcn Posted September 23, 2010 Share Posted September 23, 2010 Hi, I am using php dynamic listing from database. it is working but I wanna integrate to a horizontal css menu how can i integrate my codes to any css horizantal dropdown menu. thans. here my dynamic list. <?php function sinirsiz_kategori($parent) { $sql = mysql_query("SELECT * FROM kategoriler ORDER BY id DESC"); while($row = mysql_fetch_array($sql)) { $diziler[$row['id']] = array('baslik' => $row['baslik'],'parent' => $row['parent']); } $has_childs = false; foreach($diziler as $key => $value) { if ($value['parent'] == $parent) { if ($has_childs === false){ $has_childs = true; echo "\t<ul>"; } echo "<li><a href=\"".$value['baslik'].".php\">".$value['baslik']."</a>"; sinirsiz_kategori($key); echo "</li>\n"; } } if ($has_childs === true) echo "</ul>"; } ?> <?=sinirsiz_kategori(0)?> Link to comment https://forums.phpfreaks.com/topic/214229-dynamic-css-menu/ Share on other sites More sharing options...
taquitosensei Posted September 23, 2010 Share Posted September 23, 2010 search google for css menu tutorial pick one and change your classes/html structure to match. Link to comment https://forums.phpfreaks.com/topic/214229-dynamic-css-menu/#findComment-1114722 Share on other sites More sharing options...
fortnox007 Posted September 23, 2010 Share Posted September 23, 2010 give your elements Classes or ID's like: <p class="monkey"></p> use an external css to assign properties like . monkeys{ // for a Class background-color: #cccccc; } Now if you want to make classes dynamic you could put php inside the class =" " Like: <?php $class = 'monkeys'; ?> <p class="<?php echo $class ;?>">your text inside here</p> You can ofcourse also use heredocs echo's and much much more but this is the general idea. - edit: Lol i think i gave an answer to a complete different answer But in fact it still applies to your code. this way you can switch from horizontal to vertical class dynamically. But the horizontal menu in css is a reall css thing Link to comment https://forums.phpfreaks.com/topic/214229-dynamic-css-menu/#findComment-1114731 Share on other sites More sharing options...
dgnzcn Posted September 23, 2010 Author Share Posted September 23, 2010 thanks for answers, but i am newbie for php.. can you show in my codes please ?? Link to comment https://forums.phpfreaks.com/topic/214229-dynamic-css-menu/#findComment-1114740 Share on other sites More sharing options...
fortnox007 Posted September 23, 2010 Share Posted September 23, 2010 thanks for answers, but i am newbie for php.. can you show in my codes please ?? Well the thing is I showed you how to make dynamic classes. so that part is fixed. But for your horizontal menu, you should read a CSS tutorial since that is the only thing able to display your <ul> list in a horizontal manner. here is one: http://www.seoconsultants.com/css/menus/tutorial/ I just googled: "how to make a horizontal menu with css" Now ones you know how to do that. you assign those CSS properties to a class like i showed. And assign it to a HTML element (like i showed) If you followed the css tutorial and you apply the stuff above, you should be able to dynamically switch between horizontal and vertical class very easily. .horizontal{ //css properties } .vertical{ // css properties } Just first things first, learn to make a horizontal menu with CSS. Since that is what changes the way things are displayed ones you can do that it's just a matter of setting a class to your php code nothing more Link to comment https://forums.phpfreaks.com/topic/214229-dynamic-css-menu/#findComment-1114748 Share on other sites More sharing options...
dgnzcn Posted September 23, 2010 Author Share Posted September 23, 2010 ok thanks Link to comment https://forums.phpfreaks.com/topic/214229-dynamic-css-menu/#findComment-1114792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.