Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


Advertisements:




SuperbHosting.net & Arvixe.com have generously sponsored dedicated servers and web hosting to ensure a reliable and scalable dedicated hosting solution for BigResource.com.







Using Php To Display Unordered List


I have a (MySQL-)database table with columns like:

id ¦ study ¦ parent_id

How do I display (using php) a tree that looks like this:


<ul>
<li>category A</li>
<ul>
<li>sub category A-1</li>
<li>sub category A-2</li>
<li>sub category A-3</li>
</ul>
<li>category B</li>
<ul>
<li>sub category B-1</li>
<li>sub category B-2</li>
</ul>
<li>category C</li>
<ul>
<li>sub category C-1</li>
<li>sub category C-2</li>
</ul>
</ul>


View 1 Replies (Posted: 1:29 pm on Nov. 20, 2005)

Sponsored Links:

Related Forum Messages:
Create Unordered List Tree Menu From Data Stored In An Table With The Adjacency List Model?
I need to create a tree menu of "nth" subcategories. I settled on using the adjacency list model for my table structure, because I won't be updating this table very much and this seemed the easiest to implement for my use. I want to style the output using "ul" and "li" tags...I already have a css and jquery solution to do the styling. My problem comes from pulling the data out of the database and using a recursive function via PHP to build the list ... the list is a concatenated string that gets parsed to build the tree. I'm really having a hard time getting the closing "ul" and "li" tags to line up just where they need to be.

Here's my table structure: portfolio_id (int), p_name (varchar), parent_portfolio_id (int) Here's what I want the data to look like when presented:

<ul>
<li>Portfolio Name
<ul>
<li>Sub portfolio A
<ul>

[code]....

Posted: Mar 24 10 at 22:59

View 2 Replies!   View Related
Css - Add Odd/even Loop To Unordered List?
Here an example my wordpress post. I want to add some class to the last of <li>

something like <li class='lastli'>
<ul class="tabs">
<?php
global $post;
$myposts = get_posts('numberposts=3');

[code]......

The results I wanted to be like :

<ul>
<li>Title 1</li>
<li>Title 1</li>
<li class='lastli'>Title 1</li>
<ul>

Any last of unordered lists will be <li class='lastli'>. Let me know how to do that?

Posted: Aug 10 10 at 3:05

View 3 Replies!   View Related
How To Create Unordered List
I am creating an Org Chart and I cannot seem to figure out a way to have php create an unordered list in the proper format. Here is my code;

MySQL Database
| category_id | name | lft | rgt |
list_view,php
Code:
<?php
$localhost = "";
$sql_username = "";
$sql_password = "";

[Code]....

Posted: Feb 4, 2009, 12:06

View 9 Replies!   View Related
Wrap Every 5 Results In Unordered List?
I have an array containing a "Variable" amount of results/entries.

I use foreach as normal to echo the array results.

Problem: I want to wrap every 5 results from the array in Unordered list.

I do not know the total number of results since it's variable. So for example if it contains 18 items. It should display 4 ULs, the first 3 ULs containing 5 results and the last UL contains only the remaining 3 items.

Posted: Nov 12 10 at 19:25

View 5 Replies!   View Related
Add A Class To A Child Unordered List?
I've successfully added a few classes to the first ul in wordpress' template tag: wp_page_menu, however, I haven't been able to add a class to the child ul nested in the first li.

Code:
1.function add_menuclass($ulclass) {
2.return preg_replace('/<ul>/', '<ul class="clearfix rMenu-hor rMenu">', $ulclass, 1);

[code]...

Posted: 01-01-2010, 08:14 PM

View 1 Replies!   View Related
Dynamically Populate An UnOrdered List?
I am attempting following code to populate an UnOrdered List dynamically. The same type of code I am successfully using to populate a DropDown. But when I changed the tags to UnOrdered List, it is not working. When run, it just displays some tags instead of the actual output.Where is the error:

<?php
[code].........

Posted: Jan 16 10 at 7:40

View 4 Replies!   View Related
Creating Simple Unordered List Menu From XML?
Does anyone have any examples or links to examples of generating a
simple unordered list menu with multiple levels from an XML file? We
are redesigning the navigation on our website and I was hoping to make
this as flexible as possible.


Posted: July 17th, 2005 04:57 AM

View 1 Replies!   View Related
Building Unordered List Navigation Menu?
I wrote a dynamic menu based on three table on db which reflects below level frame:

> Section
>> Categories
>>> Subcategory

Here is my code:

include("connDB.php");
echo '<ul>';
$q1 = mysql_query("SELECT * FROM section ORDER BY section_name ASC");
while($getSection = mysql_fetch_array($q1)) {

[code]....

Posted: Apr 29 at 7:02

View 1 Replies!   View Related
Html - Add Dynamic Classes To An Unordered List?
I'm trying to add consecutive classes to all list-items in a list with the class of 'nav'. Essentially, I want every list-item to have a class of 'nthChild-x', where x represents its position in the list. I'm a major noob to PHP, so be easy.

Here is the current markup:

<ul id="primaryNav" class="nav">
<li>Blah Blah Uno</li>
<li>Blah Blah Dos</li>
<li>Blah Blah Tres</li>
</ul>

I want this list to be rendered as the following:

<ul id="primaryNav" class="nav">
<li class="nthChild-1">Blah Blah Uno</li>
<li class="nthChild-3">Blah Blah Dos</li>
<li class="nthChild-3">Blah Blah Tres</li>
</ul>

I know how to do this with JS but need this to be server-side. Also, I don't necessarily want to target the ID of the list because I'd rather do it once and target all lists (though that could be a start).

Posted: Jun 8 at 0:13

View 3 Replies!   View Related
Nested Unordered List For Menu ( Arrays )?
I'm confused as to how to use an associative array to produce a menu with a nested UL. For example, the result I'd like to achieve is:

Code:
<ul>
<li><a href="page1.html">Page 1</a></li>
<li><a href="page2.html">Page 2</a>
<ul>
<li><a href="page2-1.html">Page 2-1</a></li>

[Code]...

Posted: Apr 28, 2009, 14:32

View 2 Replies!   View Related
Reading HTML Unordered List Into Multidimensional Array
I have some software (Wordpress, actually) that is sending HTML code of an unordered list when I call a particular function. I want to make that list into a multidimensional array. So something like this: Code:

Posted: May 09, 2007, 09:53:19 PM

View 3 Replies!   View Related
Build An Unordered List Dynamically From Json Data
How do I modify this function that dynamically builds a drop down list so that I could build an un-ordered list dynamically from json data.

</script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
jQuery .getJSON("http://127.0.0.1/conn_mysql.php", function (jsonData) {
$.each(jsonData, function (i, j) {
[Code]......

*spec_list* is id of drop down i.e. 'select' here & options i.e. in (j.options) is the field in table which data is received as json. I have 'msg' only table field now which data is to be used to dynamically populate 'ul id="msg"'.

Posted: Nov 28 10 at 13:00

View 1 Replies!   View Related
Multidimensional Array To Unordered List, Building Up Url Path?
I have a multidimensional array in PHP produced by the great examples of icio and ftrotter (I am use ftrotterrs array in arrays variant):Turn database result into arrayI have made this into a unordered list width this method:

public function outputCategories($categories, $startingLevel = 0)
{
echo "<ul>

[code]...

Posted: May 26 at 10:46

View 2 Replies!   View Related
Created Style Status Update To An Unordered List?
I've a Facebook/Twitter where the new Status' get added to . I now want to add a "REMOVE" function to it, however, I'm not sure how to best accomplish this. n my list item, create my [a] tag with the unique ID of the status post ID and set a listener classHave jQuery listen for [a] tags with the listener classPOST the ID over to the PHP script to remove the post; if successful return with "ok" or if failed return with "fail"In the callback function, if it's OK, then find the element and remove it

Posted: Jan 18 10 at 20:32

View 1 Replies!   View Related
How Can Strip The Text Bullet And Then Make That Copy An Unordered List In The HTML?
I have some text coming into a web page from a MySql DB that contains bullets in the copy. The copy cannot be changed as it is also used in a Quark Xpress document we have connected to the DB. So, my question is how can strip the text bullet and then make that copy an Unordered list in the HTML?

This is what I have but and does the indents like a list but no bullets (I guess they are being stripped by the str_replace as well?

echo str_replace(Chr(13), "<p>", ("<ul>".str_replace('•', '', $bulletcontent1)."</ul>"));

Posted: 04-04-2006, 11:27 PM

View 2 Replies!   View Related
Unordered List Replace Bullet By Image According To Level If Last Level Text As Link?
I was wondering if there is a way to change the the look of wach level of a list. Ex:

Last level, text = link

1st level, has 1 image instead of bullet and text in bold

2nd level as another image as bullet and text in bold

3rd level, if not last level, as another image as bullet and text in bold

Here is where I'm now :

PHP Code:

<html>
<head>
<style type="text/css">

[code]....

Posted: January 31st, 2010, 10:19 AM

View 5 Replies!   View Related
Convert A (nested)HTML Unordered List Of Links To Array Of Links?
I have a regular, nested HTML unordered list of links, and I'd like to scrape it with PHP and convert it to an array. The original list looks something like this:

<ul>
<li><a href="http://someurl.com">First item</a>
[code]....


Posted: Apr 11 10 at 15:14

View 1 Replies!   View Related
Drupal - List Of Events With A List Of Timestamps, Grouped By Hour In A Tabular Display?
While refactoring, I am looking for an optimised algorithm for a timetable (calendar) in PHP. I have a list of events which have a list of timestamps. This must be presented in a tabular way. The current code works, but has a) quite some quircks and is b) very inflexible. I am looking to refactor this piece and looking for input on optimised ways.

Example here, notice the header of the table bearing the hours. And the times within that hour being grouped in that column. One event, having two timestamps in one hour can be ignored (may only happen in theory, as per the technical docs)

The table is built with Drupals theme_table(), which I can build up from any array, bearing arrays for each row. the Drupal part, however, is of little interest here :)

Current code (snippets):

<?php
//inside function that builds the content for the page linked to above:
$this_morning = _playdates_get_start_of_day_with($timestamp);
$this_night = _playdates_get_end_of_day_with($timestamp);
$nodes = _playdates_load_all_in_range($types, $this_morning, $this_night);
usort($nodes, '_playdates_cmp_titles');
//we now have a list of "nodes", being the events listed in the first column, which have
// a list of playdates, the timestamps. $node->nid is a unique id for each event.
foreach ($nodes as $node) {

[Code]...

Posted: Oct 8 10 at 7:46

View 2 Replies!   View Related
Unordered Word Search
I've built a search engine that queries a MySQL database. However,
if I enter "foo bar", the engine will search for that phrase exactly,
and will not find "bar foo" nor "foo something bar". How do you
separate words so that the engine finds them individually? I'm thinking
something like

$tokenized = strtok($query, " ")
mysql_query(" SELECT ... FROM ...
while(...){ WHERE ...}
")

Posted: December 28th, 2005 11:05 AM

View 2 Replies!   View Related
Dynamic Unordered Lists
I have searched about for this one but havent quite found the low down i'm looking for but here goes.

I'm trying to dynamically populate an unordered list from an SQL database which will have upto 5 or 6 sub-selections per top level list item so.. it would do something like this: Code:

Posted: 01-06-2006, 04:17 PM

View 1 Replies!   View Related
Unordered Input Args
<?php

function myfunc($i, $j){
return($j);
}

echo myfunc($j=6, $i=3);
?>

I know this doesn't work, but is there some way to do unordered list for input arguments to a function? I want the above function to return 6 by only manipulating the function call.

Posted: 07-30-2007, 08:31 PM

View 3 Replies!   View Related
Move Next With Unordered ID Column?
I'm trying to move to the next record in a query using php/MySQL A simplified query is below:

$result = mysql_query("SELECT id FROM table ORDER BY datefield, id ASC");
$row = mysql_fetch_object($result);
$id = $row->id;

This simply selects the table data and orders it by a date field first, then id.Normally, if the query was only ordered by ID, we could be assured that the ID was increasing as we move forward row by row. If this was the case, to get the next row I would use:

$next_result = mysql_query("SELECT id FROM table WHERE id > '$id' ORDER BY id ASC LIMIT 1
$next_row = mysql_fetch_object($next_result);
$next_id = $next_row->id;

This normally works perfectly, however the problem here is that the primary order of the initial query is by a date field, then ID. The date field does not necessarily have any relation to the order of the ID

That means that you can get data ordered like this:

Date | ID
2010-08-01 | 1
2010-08-01 | 4
2010-08-02 | 3
2010-08-02 | 2

You can probably see the problem here.. we cannot move next by simply getting the next highest ID in the query because the ID is not in increasing order.

Posted: 07-30-2010, 11:55 PM

View 3 Replies!   View Related
Display List
i'm trying to create a script that - when a visitors visits the page- shows all duplicate entries of a certain field (field is called 'ip'). The script should check the database (column = users) and should list all accounts a ip address has (if it has more than one). If there is only one account for an IP it shouldn't be shown. Only when multiple accounts are made by the same IP i would like it to be listed in a table like : [ip] [accountname1,accountname2,...]

Posted: 09-29-2006, 04:20 PM

View 7 Replies!   View Related
How To Automatically Display From A List Box?
I am working on a PHP/HTML form which supports End User queries.

I need the user to select a combination of Airline and corresponding
place of Origin. i,e
Delta - Madison, Dallas, Atlanta
KLM - Amsterdam, Houston, Detroit
Brit - New York, London, Seattle

I have a list of Airlines in a list box. The moment the user selects an
Airline(Delta) from the List box, the list box below it needs to have
(Dallas, Atlanta, Madison) as its options.

How is this done? How do I use a listbox selection as a trigger an
automatically start the next activity?

Posted: July 17th, 2005 12:41 PM

View 9 Replies!   View Related
PHP To Display Drop Down List
I'd like to have 3 drop down lists connected.

Division
Department and
Section

Where the options of Department are dependent on what is selected in Division and the options of Section are dependent on what is selected in Department. So far, all the examples I've found have been using JavaScript. Can I do this in PHP as I have no knowledge of JavaScript at all.

Posted: 01-06-2007, 12:47 AM

View 6 Replies!   View Related
Display A List Of Categories?
On single.php I want to display a list of categories, similar to the one using the_category but instead links to archive of these categories, I want links to RSS feed of these categories.

Is there a way to do this, without a plugin?

Posted: Jul 29 10 at 18:12

View 1 Replies!   View Related
Display Dropdown List For Each Row
i have a question regarding dropdownlist in php file. If i have a table with 3 columns and 3 rows ,in the last column i have to display dropdown list for each row. I am able to display dropdownlist under the table but i am not able to display it inside the table for each row. how to display a drop down list in each row of the table. Note: i am getting dropdownlist data from mysql database table.ie.from a row in a table.

Posted: Oct 23rd, 2010

View 1 Replies!   View Related
Display A Dropdown List?
I think I'm nearly there, I just want to display a drop down list

Code: [Select]<ul>
<li><form name="form3" method="post" action="">
<select name="menu2" onChange="MM_jumpMenu('parent',this,0)" class="textbox">
<option value="">Please choose a town!</option>
<?php while($row = mysql_fetch_array($result))
{
echo '<option value="pub_info.php?rsTown='.row['rsTown'].'">';
[Code].....

my error lies on line 465 which is this bit: Code: [Select]echo '<option value="pub_info.php?rsTown='.row['rsTown'].'">'; echo ''.row['rsTown'].' ('.$total_pages.')</option>';

but I think my code is just a mess?! what do you think?

Posted: December 06, 2010, 07:11:55 AM

View 1 Replies!   View Related
Display A List Of Files In A Folder
How do you display a list of files in a folder and then delete one by clicking on it?

Posted: February 22nd, 2002, 10:39 AM

View 3 Replies!   View Related
How To Display .txt Info Into Drop Down List
list out all the items from a file (data.txt) into drop down box for user to select.

Eg. inside (data.txt) has
Apple
Orange
Strawberry
etc...

How do I create a drop down list that can call out everything from data.txt (until end of file)??

Posted: August 15, 2007, 01:04:48 PM

View 2 Replies!   View Related
Display List Of Logged In Users
I'm making a small website that includes a user login/logout feature. Its a friendly site and isn't anything fancy. What I'm working on now is to display a list of all the users that are currently logged in the website. The system I'm using now is basically a table ("current_users") that contains all the usernames of users that have successfully logged in. The table would fill as users logged in and empty as users log out. The problem is what if the user never clicks "logout" (and thus never executing the script that removes that user from the table), but simply closes the browser? The table would then never have a chance to remove that user from an "logged in" status.

Posted: 5:11 pm on Jan. 16, 2007

View 1 Replies!   View Related
Display From Database To Dropdown List?
I have stored value from drop down list to database. I want to echo the same value to be displayed in that drop down list in my edit form. how can I achieve that in php?

Region
<select name="stf_region">
<option>Select</option>
<option value="1">MDU</option>
<option value="2">TMM</option>
</select>

i have stored in database using value of selectionbut i dont know to display that value in same drop down

Posted: Jul 5 at 12:40

View 6 Replies!   View Related
Display The Array In A List Of Records?
I have an array as

MyArray
(
[0] => Array
(
[0] => Array
(

[Code]....

Now I want this Array to be displayed in a List of records, i.e. below given namings are headers of the fields to be displayed in a single row

Vendor Name |Beneficiary Name | LPO NUMBER | LPO DATE | LPO AMOUNT | AMOUNT | ADDITIONAL DESCRIPTION

Here the Two Rows TO be Displayed will be for array MyArray[0] and MyArray[1], I Need it to be work dynamically..

Posted: Apr 10 at 7:13

View 2 Replies!   View Related
Display A Set List Of Products Using Columns?
This is really just a general question that I am quite interested in developing.

Say I had a list of products with the following attributes right?

productid = 1 (smallint(3))
productname = "Product 1" (varchar, to reduce space)
price = 25.99 (double, more precise for currency?) -

But say this spanned out to say 6 products per line on the user viewing the page.

With then 5 rows down.

product1 | product2 | product3 | product4 | product5 | product6
product7 | product8 | product9 | product10 | product11 | product12

And so on until all products have been displayed right?

How would I do this theoretically in PHP to limit that no of results per row?

Always been confused on how this is doable, want to eventually construct my own ecommerce, really get into the nuts and bolts of it.

Posted: February 03, 2011, 07:24:09 AM

View 2 Replies!   View Related
Display Missing Value In List Code?
I am trying to figure out a way to have php give me the next "available" value, in a list.  This seems easy enough, but there may be some values that have a letter in them.  So for example, if I have this:

1
2
3

[code]...

Posted: May 03, 2010, 12:44:50 AM

View 3 Replies!   View Related
Display List Of Tables In A Database?
am just trying to display a list of tables from a database. The catch is that I was to display all the tables except for the table "user" and "thumbnails". does anyone know how to write exceptions?

Posted: Jun 29, 2010, 12:50

View 3 Replies!   View Related
Display List Of Cars From MySQL?
I have a table, with about a hundred cars in it. There's three columns, id, car name, and one for manufacturer. What I'd like to do, is display a table listing all manufacturers and how many cars each has assigned to it. For example, say I have 5 Dodge cars in the table and 7 Fords. I'd like it to look like this:

Dodge | 5
Ford | 7

etc... for all manufacturers. I think I would have to use some form of COUNT() in my query correct?

Posted: July 12, 2011, 09:47:10 PM

View 8 Replies!   View Related
Display A Certain List Of Days Using Date()?
Basically,  I need to prefill a select drop down box with the sunday of each week. I would like to it to basically be in the format of:

<select name="row_date">
<option value="2010-01-01">2010-01-01</option>
<option value="2010-01-08">2010-01-08</option>
<option value="2010-01-15">2010-01-15</option>
<option value="2010-01-22">2010-01-22</option>

[Code]...

But it would automatically select the current week (as the default value) and allow the user to change that.. but only from the displayed dates. I wouldn't need more than 6 weeks to be shown, but that's not too important. I've researched this forum, php.net and Google to no avail.

Posted: March 10, 2010, 10:10:40 PM

View 4 Replies!   View Related
Display List Of Countries - Categories?
I have a list of countries and categories which are not in database. What is the best way to display them when I need them if I don't use object programming?

Let's say I have 30 categories.
$country_list = array(
'1'=>"category1",
'2'=>"category2",
'3'=>"category3"
...
);

Is the best way to create file lists.php and then I put into this file all lists? Than I require_once this file in every page. Or is better to create function show_lists($listsName) and store inside all lists?

Posted: July 08, 2010, 02:23:21 PM

View 2 Replies!   View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved