Google Answers Logo
View Question
 
Q: PHP ( No Answer,   3 Comments )
Question  
Subject: PHP
Category: Computers > Programming
Asked by: universityresource-ga
List Price: $40.00
Posted: 04 Nov 2004 05:20 PST
Expires: 07 Nov 2004 11:12 PST
Question ID: 424307
Hi, 
We would like the PHP for the following:
We have a data set in two tables in MySQL on PHP.
Table1 contains data, table2 contains relationships between items in table1

Table1
Entry_id
Notes

Table2
PrimaryKey
Up (contains a Table1.entry_id)
Down (contains a Table1.entry_id)

This is the data:

             1                        2
       3   4     5                    6
     7  8      9   10
     

The numbers refer to entry_id's of notes in table1.  The positions
refer to the relative organization in table2.

We would like the data to display in the following order:
1
3
7
8
4
5
9
10
2
6


If you need sample data or more detail I can provide.
 


 Clarification of Question by universityresource-ga on 03 Nov 2004 05:11 PST 
Also,
If we could associate a new field called "Level" with each item that
would represent its level, for instance:
Entry_id 1 and 2 would have a Level=1
Entry_id 3,4,5 and 6 would have a level=2
Entry_id 7,8,9 and 10 would have a level=3
and so on..

Thank you.
 


 Clarification of Question by universityresource-ga on 03 Nov 2004 05:51 PST 
Sample Data:
Table1
Entry_id, note
    1 note
    2 note
    3 note
    4 note
    5 note
    6 note
    7 note
    8 note
    9 note
   10 note

Table2
Key   Up Down
  1    1  3
  2    1  4
  3    1  5
  4    2  6
  5    3  7
  6    3  8
  7    5  9
  8    5 10
 
Server is Linux and the data connects are standard so include(connection.php)
MySQL version 4.0
PHP version 4.3

Clarification of Question by universityresource-ga on 05 Nov 2004 16:16 PST
Here are the items you requested.   The relationships between data
items in Table1 (GoodOrgPerson) are stored in Table2
(GoodOrgPRelations).  The order of retrieval we are looking for is
from the top through each element linking to the bottom, Then up to
the nearest junction, across, and so-on.




CREATE TABLE `DataSite`.`GoodOrgPersonCopy` (
 `Entry_id` int( 10 ) NOT NULL AUTO_INCREMENT ,
 `User_ID` int( 10 ) default '0',
 `Name` varchar( 150 ) NOT NULL default '',
 `Position` varchar( 150 ) default '',
 `Description` text,
 `Image` blob,
 `Image_type` varchar( 255 ) default '',
 `Notes` text,
 `Created` timestamp( 14 ) NOT NULL ,
 PRIMARY KEY ( `Entry_id` ) ,
 KEY `Name` ( `Name` ) ,
 KEY `User_ID` ( `User_ID` ) 
) TYPE = MYISAM ;


INSERT INTO `GoodOrgPersonCopy` ( `User_ID` , `Name` , `Position` ,
`Description` , `Image` , `Image_type` , `Notes` )
VALUES ( 101, 'Course # and Name', 'Professor', 'Course Objectives',
NULL , '', NULL ) , ( 101, 'Title', 'Your Name', 'Executive
Summary\r\n\r\nExplain why the research was done, the findings and
what they mean, also what action or policy your results support.
\r\nor\r\nA nontechnical quick overview. \r\nor\r\nA preview that
sells you and your work, entices the reader to begin, the editor to
buy, the producer to produce.', NULL , '', NULL ) , ( 101, '1st Major
Point', '', '', NULL , '', NULL ) , ( 101, '2nd Major Point', '', '',
NULL , '', NULL ) , ( 101, '3rd Major Point', '', '', NULL , '', NULL
) , ( 101, 'Conclussion', '', '', NULL , '', NULL ) , ( 101,
'Introduction', '', '', NULL , '', NULL ) , ( 101, 'supporting
material', '', '', NULL , '', NULL ) , ( 101, 'supporting material',
'', '', NULL , '', NULL ) , ( 101, 'supporting material', '', '', NULL
, '', NULL ) , ( 101, 'supporting material', '', '', NULL , '', NULL )
, ( 101, 'supporting material', '', '', NULL , '', NULL ) , ( 101,
'supporting material', '', '', NULL , '', NULL )

// note that I have set User_ID to 101 in all the User_ID fields.  In
the php these are populated by $_SESSION["USER_ID"]









CREATE TABLE `DataSite`.`GoodOrgPRelationsCopy` (
 `Relation_id` int( 10 ) NOT NULL AUTO_INCREMENT ,
 `User_ID` int( 10 ) default '0',
 `Superior` int( 10 ) NOT NULL default '0',
 `Subordinate` int( 10 ) NOT NULL default '0',
 `RelationType` varchar( 150 ) default '',
 `Description` varchar( 255 ) default NULL ,
 `Notes` varchar( 255 ) default NULL ,
 `Created` timestamp( 14 ) NOT NULL ,
 PRIMARY KEY ( `Relation_id` ) ,
 KEY `Superior` ( `Superior` ) ,
 KEY `Subordinate` ( `Subordinate` ) ,
 KEY `User_ID` ( `User_ID` ) 
) TYPE = MYISAM ;



INSERT INTO `GoodOrgPRelationsCopy` ( `User_ID` , `Superior` ,
`Subordinate` , `RelationType` , `Description` , `Notes` )
VALUES ( 101, 1, 2, '', NULL , NULL ) , ( 101, 2, 3, '', NULL , NULL )
, ( 101, 2, 4, '', NULL , NULL ) , ( 101, 2, 5, '', NULL , NULL ) , (
101, 2, 6, '', NULL , NULL ) , ( 101, 2, 7, '', NULL , NULL ) , ( 101,
3, 8, '', NULL , NULL ) , ( 101, 3, 9, '', NULL , NULL ) , ( 101, 4,
10, '', NULL , NULL ) , ( 101, 4, 11, '', NULL , NULL ) , ( 101, 5,
12, '', NULL , NULL ) , ( 101, 5, 13, '', NULL , NULL )


// Again User_ID has been populated with 101, and in php would be
populated by $_SESSION["USER_ID"]
The values for Superior and Subordinate are filled in however these
relate to GoodOrgPerson.Entry_id data that we inserted above, so we
have to retrieve the Entry_id of the inserted data.

Clarification of Question by universityresource-ga on 05 Nov 2004 16:41 PST
To clarify the data retrieval order, the idea is to organize the data
hierarchically for display.

In the example shown 1 and 2 would be Major Headings, 3,4,5,and 6
would be subheadings.  7 and 8 would be items supporting 3.
 9 and 10 would be items supporting 5.

The display order should be:
Heading1
Subheading3
Supporting material 7
Supporting material 8
Subheading4
Subheading5
Supporting material 9
Supporting material 10

Heading2
Subheading6
Answer  
There is no answer at this time.

Comments  
Subject: Re: PHP
From: jho7-ga on 05 Nov 2004 14:53 PST
 
Please post the following:

1) DDL for all tables used
2) INSERT statements for all data

Thank you.
Subject: Re: PHP
From: jho7-ga on 05 Nov 2004 15:06 PST
 
... Also, please explain the relation ship between table1 and table2,
as well as how you ended up getting the order 1, 3, 7...

Thank you.
Subject: Re: PHP
From: mathtalk-ga on 05 Nov 2004 16:03 PST
 
Hi, jho7-ga:

You might get some additional background for this Question from a previous post:

http://answers.google.com/answers/threadview?id=423817

regards, mathtalk-ga

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy