Currently I've a database table call category:
Table attribute: id,parent_id,name

How can I make it display in the following structure?

<li class="dropdown level-0"><a href="#">electronics<img src="images/dropdown-arrow.png" alt="" /></a>
                    <ul>
                        <li class="level-1"><a href="#">Televisions</a>
                            <div class="level-1-div clearfix">
                                <ul>
                                    <li class="level-2"><a href="catalog.html">Projectors</a></li>
                                    <li class="level-2 last-level-2"><a href="catalog.html">DVD Players</a></li>
                                </ul>                                

                                <div class="productImageDiv">
                                    <a href="catalog.html"><img src="images/product-image2.png" alt="" /></a>
                                </div>
                            </div>
                        </li>
                        </ul>
                        </li>

Recommended Answers

All 4 Replies

Hello sir, Can we see your code for gathering the data from your database.

Thank you!!

Do you mean SQL Query?

The most important component here is to the get your SQL query correct. Once you have that, its a matter of creating the logic to echo the structure you are looking for, plugging in the variables in the correct location within your <li/> elements.

Please help me. This is my query

SELECT * FROM category 

My table columns is : id,parent_id,name

Please help me structure a php code to suit the html code above . Please

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.