I have a problem with my code What is the best way to show all the sub pages for parents' pages, Whether you are watching a parent or child page or not? If a different guardian is chosen, then the pages of the previously selected parent's child should be hidden.
All pages have an ID in the URL that is available using $ _GET ['id'].
My MYSQL db looks like this.
If no pages exist, create an ID (`id 'int (11) faucet auotoncrment,' title 'varchar (255) zero,` parent` integer (11 ) No, Primary Key (`ID`)) Engine = InnoDB Default Charge = latin1 AUTO_INCREMENT = 8; I currently have the page with the code, if you are on the original page, the child's pages are displayed, but as soon as you jump on any hair page, the child page disappears. Are done.
$ gparents = mysql_query ('select db.pages where parent = 0'); While ($ parents = mysql_fetch_assoc ($ gParents)) {resonant '& lt; A href = "? Id = '. $ Parent [' id ']." "Parents ['Title']. ' & Lt; / a & gt; & lt; br / & gt; '; $ $ QChilds = mysql_query (' Choose from * db.pages where parent = '. $ Parent \' id ']. And parent = '. $ _GET [' id ']); while ($ childs = mysql_fetch_assoc ($ qChilds)) {echo'
Perhaps I can try to understand my question using an example. Suppose you have the following records in the table:
< Code> id title guardian 1a 2 b3c 4a1 1 5 a2 1 6 b 1 2 7 c 1 3 8 c 2 3 9C3 3 Your above code will generate an output like this in the first place, i.e. list of all parent categories and their child categories:
A a1 a2 b b1 cc 1 c 2 c3 Your requirement is that if someone clicks on a parent category, then say "A", only one Only child categories should be shown and all the hair categories of "B" should be hidden and "C" Okay?
In addition to this, if a person clicks on the child category, even then he should show the same result as someone clicked on the parent's page.
If your understanding is correct on my requirement, you can fix your code by passing a parent-id instead of child-id in the child-link, as indicated below:
$ gparents = mysql_query ('SELECT * fROM db.pages WHERE parent = 0'); While ($ parents = mysql_fetch_assoc ($ gParents)) {resonant '& lt; A href = "? Id = '. $ Parent [' id ']." "Parents ['Title']. ' & Lt; / a & gt; & lt; br / & gt; '; $ $ QChilds = mysql_query (' Choose from * db.pages where parent = '. $ Parent \' id ']. And parent = '. $ _ Meet [' id ']); while ($ childs = mysql_fetch_assoc ($ qChilds)) {echo' & lt; a href = '? Id = '. $ Parents ['ID']. "" & Gt; '. $ Childs ['title']. ' & Lt; / A & gt; & Lt; Br / & gt; ';; }} As a sidenote, if it is not absolutely necessary, then it will probably understand that there is no link to hair categories?
The hope of the above helps!
No comments:
Post a Comment