Ok, here's what I got.  I'm trying to create an entire site that grabs 
all it's information (Page content, titles, link info, etc.) from a 
MySQL database.  In this site I would like to have sub pages of master 
pages.  For instance, Page 1 is a master page, Page 2 is a sub page of 
Page 1, and Page 3 is a sub page of Page 2 which is a sub page of page 
one.  Now I would like to display this entire hierarchy if possible.  
Here's what I have but either I get an infinite loop or it doesn't work 
worth a damn....

<?
mysql_connect("127.0.0.1","webuser","");
$query="SELECT * FROM PageInfo WHERE PageID>'0' and PageID=$MasterPage 
ORDER BY PageID";
$VARS="";
do {
        $result=mysql_db_query("DynamicDB",$query);
        $count=(mysql_num_rows($result));
        if($count>0) {
                while($r=mysql_fetch_array($result)) {
                        $LinkText=$r["LinkText"];
                        $FileName=$r["FileName"];
                        $LinkAlt=$r["LinkAlt"];
                        $MasterPage=$r["MasterPage"];
                        $PageID=$r["PageID"];
                        $VARS="$PageID ".$VARS;
                        echo "$PageID<br><br>";
//                      echo "$VARS";
                }
        } else {
        }
        $query="SELECT * FROM PageInfo WHERE PageID>'0' and 
PageID=$MasterPage";
} while ($MasterPage>0);
//echo "$VARS";
$PageIDs=explode(" ",$VARS);
$i=0;
while(strlen($PageIDs["$i"])>0) {
        $TheVar=$PageIDs["$i"];
        $TheQuery="SELECT LinkText, FileName, LinkAlt FROM PageInfo where 
PageID=$TheVar";
        $TheResult=mysql_db_query("DynamicDB",$TheQuery);
        $TR=mysql_fetch_array($TheResult);
        $TheLinkText=$TR["LinkText"];
        $TheFileName=$TR["FileName"];
        $TheLinkAlt=$TR["LinkAlt"];
        echo "<font color=\"#000000\"><b><a href=\"$TheFileName\" 
alt=\"$TheLinkAlt\">$TheLinkText</a></b></font>";

        $i++;
}
?>

My table structure looks like this....

+------------+------------------+------+-----+----------+---------------
-+
| Field      | Type             | Null | Key | Default  | Extra         
 |
+------------+------------------+------+-----+----------+---------------
-+
| PageID     | int(40)          |      | PRI | NULL     | 
auto_increment |
| PageType   | varchar(6)       |      |     | master   |               
 |
| LinkText   | varchar(20)      |      |     | linktext |               
 |
| FileName   | varchar(30)      |      | PRI |          |               
 |
| LinkAlt    | varchar(100)     | YES  |     | alttext  |               
 |
| Contents   | longblob         |      |     |          |               
 |
| MasterPage | int(11) unsigned | YES  |     | 0        |               
 |
| Active     | char(3)          |      |     | yes      |               
 |
| LinkOrder  | mediumint(9)     | YES  |     | 99       |               
 |
+------------+------------------+------+-----+----------+---------------
-+
9 rows in set (0.03 sec)

Thanks in advance...

Brian


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to