Jump to content

dynamic css menu ??


dgnzcn

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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.