WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL Update Picture
Benedetto Patrice
Date : May 08th 2000
Grade : 2 of 5 (graded 15 times)
Viewed : 22011
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Benedetto Patrice
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?

/*

patrice benedetto webmestre@labynet.org ( experimental )
Input this in your mySql db before running this , so you will understand how it works :)
it allows you to get 99 heads and 1--99 categorie in each node
you may improve the warning code to get more than 3 level

#
# Table structure for table 'res_cat'
#

CREATE TABLE res_cat (
ID int(32) DEFAULT '0' NOT NULL ,
ID_uname char(40) NOT NULL,
UNIQUE ID (ID)
);

#
# Dumping data for table 'res_cat'
#

INSERT INTO res_cat VALUES( '1', 'head1');
INSERT INTO res_cat VALUES( '101', 'cat11');
INSERT INTO res_cat VALUES( '102', 'cat12');
INSERT INTO res_cat VALUES( '103', 'cat13');
INSERT INTO res_cat VALUES( '10101', 'subcat111');
INSERT INTO res_cat VALUES( '10102', 'subcat112');
INSERT INTO res_cat VALUES( '10103', 'subcat113');
INSERT INTO res_cat VALUES( '1010101', 'subcat1111');
INSERT INTO res_cat VALUES( '1010102', 'subcat1112');
INSERT INTO res_cat VALUES( '1010103', 'subcat1113');
INSERT INTO res_cat VALUES( '10201', 'subcat121');
INSERT INTO res_cat VALUES( '10202', 'subcat122');
INSERT INTO res_cat VALUES( '10203', 'subcat123');
INSERT INTO res_cat VALUES( '10301', 'subcat131');
INSERT INTO res_cat VALUES( '10302', 'subcat132');
INSERT INTO res_cat VALUES( '10303', 'subcat133');
INSERT INTO res_cat VALUES( '2', 'head2');
INSERT INTO res_cat VALUES( '201', 'cat21');
INSERT INTO res_cat VALUES( '202', 'cat22');
INSERT INTO res_cat VALUES( '203', 'cat33');
etc ...
*/
$mysql_link = mysql_connect("localhost", "user", "passwd");
mysql_select_db("res_cat", $mysql_link);
echo "<html><body>" ;

function listrub ($id , $exploseID )
{
global $PHP_SELF ;
global $mysql_link ;
$maxi = ($id*100)+100 ;
$mini = $id*100 ;
$query = "SELECT * FROM res_cat where ID < $maxi and ID > $mini " ;
echo "<ol>";
if(         $mysql_result = mysql_query($query , $mysql_link) )
{
while ($row = mysql_fetch_object($mysql_result))
        {
// you have to link some action on leaves of course
echo "<li> <a href='$PHP_SELF?ID_rub=$row->ID' > $row->ID_uname </a> </li> " ;
$testID = ($exploseID - ($exploseID %100 ))/100 ; // WARNING this is ugly .. only 3 level
if ( $testID == $row->ID || $exploseID == $row->ID)
        {
                 listrub ($row->ID , $exploseID ) ;
                }
        }
}
echo "</ol>";
}
$father =999999999; // a big number
// get the grand...grand father
if ( $ID_rub >100 )
{
$father = $ID_rub ;
while ( $father >100 ) { $father= ( $father - ( $father %100) )/100 ; }
}
else{$father= $ID_rub ;}
listrub ($father , $ID_rub ,$mysql_link ) ;
echo "</body></html>";

?>



Paginating the mySQL data
Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP
Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
Functions for loading images into a MySQL database and displaying them.
Categories : Graphics, HTML and PHP, MySQL, PHP, Databases
dynamic table columns
Categories : PHP, HTML and PHP, Arrays, Databases, MySQL
Dynamically generated pop-ups (Select items)
Categories : PHP, HTML and PHP, MySQL, Databases
Complex paging with no resultset limit
Categories : PHP, MySQL, Databases, Output Control, HTML and PHP
phpFormGenerator for Dynamic Form Generation from MySQL
Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
Required form fields that pull from MySQL database
Categories : PHP, HTML and PHP, Databases, MySQL
mySQL/PHP/search with multientry form and table output with colored rows
Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases
Storing / Retrieving pictures from database This can be used for banner / ads exchange. very useful for people developing big portal with ads in the site........
Categories : PHP, MySQL, Databases, HTML and PHP
Creating thumbnails from MySQL Blobs online
Categories : PHP, MySQL, Graphics, HTML and PHP, Databases
Editing the virtusertable and sendmail.cw via PHP3.0 and Mysql
Categories : MySQL, HTML and PHP, PHP, Databases
This function will populate the options in a drop down HTML select list in a form from a database query.
Categories : MySQL, General SQL, PHP, HTML and PHP, Databases
Record Set Paging with PHP (RSP)
Categories : PHP, MySQL, Navigation, Databases, HTML and PHP