Using Php To Display Unordered List

Nov 20, 2005

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>

ADVERTISEMENT

Create Unordered List Tree Menu From Data Stored In An Table With The Adjacency List Model?

Mar 24, 2010

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]....

View 2 Replies View Related

Css - Add Odd/even Loop To Unordered List?

Aug 10, 2010

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?

View 3 Replies View Related

How To Create Unordered List

Feb 4, 2009

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]....

View 9 Replies View Related

Wrap Every 5 Results In Unordered List?

Nov 12, 2010

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.

View 5 Replies View Related

Add A Class To A Child Unordered List?

Jan 1, 2010

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]...

View 1 Replies View Related

Dynamically Populate An UnOrdered List?

Jan 16, 2010

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].........

View 4 Replies View Related

Creating Simple Unordered List Menu From XML?

Jul 17, 2005

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.

View 1 Replies View Related

Building Unordered List Navigation Menu?

Apr 29, 2011

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]....

View 1 Replies View Related

Html - Add Dynamic Classes To An Unordered List?

Jun 8, 2011

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).

View 3 Replies View Related

Nested Unordered List For Menu ( Arrays )?

Apr 28, 2009

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]...

View 2 Replies View Related

Build An Unordered List Dynamically From Json Data

Nov 28, 2010

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"'.

View 1 Replies View Related

Multidimensional Array To Unordered List, Building Up Url Path?

May 26, 2011

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]...

View 2 Replies View Related

Created Style Status Update To An Unordered List?

Jan 18, 2010

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

View 1 Replies View Related

Reading HTML Unordered List Into Multidimensional Array

May 9, 2007

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:

View 3 Replies View Related

How Can Strip The Text Bullet And Then Make That Copy An Unordered List In The HTML?

Apr 4, 2006

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>"));

View 2 Replies View Related

Unordered List Replace Bullet By Image According To Level If Last Level Text As Link?

Jan 31, 2010

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]....

View 5 Replies View Related

Convert A (nested)HTML Unordered List Of Links To Array Of Links?

Apr 11, 2010

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]....

View 1 Replies View Related

Drupal - List Of Events With A List Of Timestamps, Grouped By Hour In A Tabular Display?

Oct 8, 2010

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]...

View 2 Replies View Related

Unordered Word Search

Dec 28, 2005

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 ...}
")

View 2 Replies View Related

Dynamic Unordered Lists

Jan 6, 2006

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:

View 1 Replies View Related

Unordered Input Args

Jul 30, 2007

<?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.

View 3 Replies View Related

Move Next With Unordered ID Column?

Jul 30, 2010

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.

View 3 Replies View Related

Display List

Sep 29, 2006

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,...]

View 7 Replies View Related

How To Automatically Display From A List Box?

Jul 17, 2005

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?

View 9 Replies View Related

PHP To Display Drop Down List

Jan 6, 2007

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.

View 6 Replies View Related

Display A List Of Categories?

Jul 29, 2010

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?

View 1 Replies View Related

Display Dropdown List For Each Row

Oct 23, 2010

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.

View 1 Replies View Related

Display A Dropdown List?

Dec 6, 2010

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?

View 1 Replies View Related

Display A List Of Files In A Folder

Feb 22, 2002

How do you display a list of files in a folder and then delete one by clicking on it?

View 3 Replies View Related

Display List Of Logged In Users

Jan 16, 2007

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.

View 1 Replies View Related

Display From Database To Dropdown List?

Jul 5, 2011

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

View 6 Replies View Related

Display The Array In A List Of Records?

Apr 10, 2011

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..

View 2 Replies View Related

Display List Of Tables In A Database?

Jun 29, 2010

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?

View 3 Replies View Related

Display A List Of Objects With Views?

May 28, 2010

I need to sort a set of content-types within a paginated page. Also I need to add filtering to the page, for example each content-type should have a set of tags and the filter needs to filter through these tags.This is a basic mockup of what this page consists of:I'm finding it quite hard figuring out the best way to do it, and if this can be done

View 1 Replies View Related

Recursive List - Get The Second Level To Display

May 25, 2010

I am trying to display a recursive list in PHP for a site I am working on. I am really having trouble trying to get the second level to display. I have a function that displays the contents to the page as follows.

function get_menu_entries($content,$which=0)
{
global $tbl_prefix, $sys_explorer_vars, $sys_config_vars;
// INIT LIBRARIES
$db = new DB_Tpl();
$curr_time = time();
$db->query("SELECT * FROM ".$tbl_prefix."sys_explorer WHERE preid = '".$which."' && config_id = '".$sys_explorer_vars['config_id']."' && blocked = '0' && startdate < '".$curr_time."' && (enddate > '".$curr_time."' || enddate = '') ORDER BY preid,sorting");
[Code]....

At the moment the content displays properly, however I want to turn this function into a DHTML dropdown menu. At present what happens with the level 2 elements is that using CSS the contents are indented using CSS. What I need to happen is to place the UL tag at the beginning and /UL tag at the end of the level 2 elements.

View 2 Replies View Related

Display A List Of (let's Say) 5 Members That Have Visited

Apr 9, 2009

how I can display a list of (let's say) 5 members that have visited my profile page recently? Shouldn't be too hard, should it?

Let's try to find a solution, since I believe more users might be interested in such a feature.

View 5 Replies View Related

How To Display .txt Info Into Drop Down List

Aug 15, 2007

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)??

View 2 Replies View Related

Display A Set List Of Products Using Columns?

Feb 3, 2011

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.

View 2 Replies View Related

Display Missing Value In List Code?

May 3, 2010

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]...

View 3 Replies View Related

Display List Of Cars From MySQL?

Jul 12, 2011

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?

View 8 Replies View Related

Display A Certain List Of Days Using Date()?

Mar 10, 2010

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.

View 4 Replies View Related

Display List Of Countries - Categories?

Jul 8, 2010

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?

View 2 Replies View Related

Display Data In Dynamic List?

May 23, 2011

This the dynamic list code that I use to display data from my db:

Code: [Select]$dynamicListBody = "";
$sql = mysql_query("SELECT * FROM products WHERE category='Body' ORDER BY id ASC");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){

[Code]...

View 1 Replies View Related

Display List Of Categories Into 3 Columns?

Nov 30, 2010

display my list of categories into 3 columns? This is the categories box file:

<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions

[code]....

View 1 Replies View Related

ADVERTISEMENT