<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Форум PHP-MyAdmin.RU &mdash; Вывод юзеров древовидно]]></title>
		<link>https://forum.php-myadmin.ru/viewtopic.php?id=3890</link>
		<atom:link href="https://forum.php-myadmin.ru/extern.php?action=feed&amp;tid=3890&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Вывод юзеров древовидно».]]></description>
		<lastBuildDate>Fri, 10 Oct 2014 05:22:29 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Вывод юзеров древовидно]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=25734#p25734</link>
			<description><![CDATA[<p>Пробуйте разобраться. Примерно должно выглядеть так.<br /></p><div class="codebox"><pre><code>function parent($parent_id) {
  $sql = &#039;SELECT * FROM table WHERE parent_id =&#039; . $parent_id;
  ...
  foreach ($rows as $row) {
    print $row[&#039;id_user&#039;];
    parent($row[&#039;parent_id&#039;]); // Рекурсия
  }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Fri, 10 Oct 2014 05:22:29 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=25734#p25734</guid>
		</item>
		<item>
			<title><![CDATA[Re: Вывод юзеров древовидно]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=25733#p25733</link>
			<description><![CDATA[<p>Да, вроде верно, переименуем столбец в PMA из n_jr на parent_id , идея ясна, только от этой перемены не меняется задача, <br />в запросе выводятся все кто имеет в parent_id = 8 , а что дальше? <br />Haunt, если можно подправте мною представленный код, чтобы условие заработало, пожалуйста...<br />Что-то <a href="http://searchengines.guru/showthread.php?t=290860">подобное тут</a>, но я не &quot;въеду&quot; как прилепить к моему коду...</p>]]></description>
			<author><![CDATA[null@example.com (Staff93)]]></author>
			<pubDate>Thu, 09 Oct 2014 21:23:25 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=25733#p25733</guid>
		</item>
		<item>
			<title><![CDATA[Re: Вывод юзеров древовидно]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=25732#p25732</link>
			<description><![CDATA[<div class="quotebox"><cite>Staff93 сказал:</cite><blockquote><p>В PMA такие ячейки: id_user , name , n_jr (это номер младшего юзера)</p></blockquote></div><p>Обычно хранится идентификатор родителя, а не дочерние. В этом случае дерево строится рекурсивно исходи из поиска по родительскому идентификатору.<br /></p><div class="codebox"><pre><code>SELECT * FROM table WHERE parent_id = 8;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Thu, 09 Oct 2014 05:45:44 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=25732#p25732</guid>
		</item>
		<item>
			<title><![CDATA[Вывод юзеров древовидно]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=25731#p25731</link>
			<description><![CDATA[<p>Дело такое:<br />-<br />Логинимся:<br /></p><div class="codebox"><pre><code>&lt;?php
include_once(&#039;include/config.php&#039;);
include_once(&#039;include/function.php&#039;);
$id_user = $_POST[&#039;id_user&#039;];
$password = md5($_POST[&#039;password&#039;]);
$select = mysql_query(&quot;SELECT * FROM ntvusers WHERE id_user = &#039;$id_user&#039;&quot;)or die(mysql_error());
$ds = mysql_fetch_assoc($select);
echo &quot;&lt;br /&gt;&quot;;
if($id_user == $ds[&#039;id_user&#039;] &amp;&amp; $password == $ds[&#039;password&#039;]){
    //Если галочка стоит запоминаем юзера
      if($_POST[&#039;sess&#039;] == &quot;on&quot;){
           $_SESSION[&#039;id&#039;] = $ds[&#039;id_user&#039;];
           $_COOKIE[&#039;id&#039;] = $_SESSION[&#039;id&#039;];
           //Перекидываем Юзера на главную
           ?&gt;
            &lt;script&gt;document.location.href=&quot;index.php&quot;;&lt;/script&gt;
           &lt;?php
    }else{
          $_SESSION[&#039;id&#039;] = $ds[&#039;id_user&#039;];
           ?&gt;
            &lt;script&gt;document.location.href=&quot;index.php&quot;;&lt;/script&gt;
           &lt;?php
     }
}else{echo exit(&#039;Введённые Вами данные не действительны&#039;);}
?&gt;</code></pre></div><p>В config.php лежит связь с MySQL её описывать нет смысла</p><p>После чего сам index.php:<br /></p><div class="codebox"><pre><code>&lt;?php include_once(&#039;include/config.php&#039;);?&gt;
&lt;?php include_once(&#039;include/function.php&#039;);?&gt;
&lt;?php
  if (!$_SESSION[&#039;id&#039;]) {
?&gt;
&lt;?php include_once(&#039;tmp/index.tpl&#039;);
}else{
      $id = $_SESSION[&#039;id&#039;];
      $select = mysql_query(&quot;SELECT * FROM ntvusers WHERE id_user=&#039;$id&#039;&quot;);
      $row = mysql_fetch_assoc($select);
      include_once(&#039;tmp/reg_index.tpl&#039;);
       if($_POST[&#039;del&#039;]){delete_acc($_SESSION[&#039;id&#039;]);
           ?&gt;
           &lt;?php
           exit;
       } 
else{ echo &quot;&quot;;}
}
?&gt;</code></pre></div><p>А далее вывод tmp/reg_index.tpl как html страницу с деревом юзеров:<br /></p><div class="codebox"><pre><code>&lt;head&gt;

        &lt;title&gt; Ваш номер входа  &lt;?=$row[&#039;id_user&#039;];?&gt;, Ваше имя &lt;?=$row[&#039;name&#039;];?&gt;&lt;/title&gt;

        &lt;style type=&quot;text/css&quot;&gt;
    .treeview { padding: 0; clear: both; font-family: Arial, sans-serif; width: 100%; }
    .treeview * { font-size: 100.1%; }
    .treeview ul
    {
        overflow: hidden; width: 100%; margin: 0; padding: 0 0 1.5em 0;
        list-style-type: none;
    }
    .treeview ul ul { overflow: visible; width: auto; margin: 0 0 0 0; padding: 0 0 0 0.75em; }
    /* класс для ul после которых нет li в родительских ветках */
    .treeview ul.l { border-left: 1px solid; margin-left: -1px; }
    .treeview li.cl ul { display: none; }
    .treeview li { margin: 0; padding: 0; }
    .treeview li li { margin: 0 0 0 0.5em; border-left: 1px dotted; padding: 0; }
    .treeview li div { position: relative; height: 1.5em; min-height: 16px; //height: 1.3em; }
    .treeview li li div { border-bottom: 1px dotted; }
    .treeview li p
    {
        position: absolute; z-index: 1; top: 0.8em; //top: 0.65em; left: 1.75em;
        width: 100%; margin: 0; border-bottom: 1px dashed; padding: 0;
    }
    .treeview a { padding: 0.1em 0.2em; white-space: nowrap; //height: 1px; }
    .treeview img.i
    {
        border-right: 2px solid; border-bottom: 0.5em solid;
        margin-bottom: -0.5em; vertical-align: middle;
    }
    .treeview a.sc
    {
        position: absolute; top: 0.06em;
        margin-left: -1em; padding: 0; text-decoration: none;
    }

    /* colors */
    .treeview li p,
    .treeview img.i,
    .treeview .sc
    { background: #fafafa; }
    .treeview ul.l,
    .treeview li p,
    .treeview img.i
    { border-color: #000000; }
    .treeview ul li li,
    .treeview ul li li div
    { border-color: #000000; }
    .treeview a,
    .treeview a.sc,
    .treeview a.sc:hover
    { color: #000000; }
    .treeview a:hover
    { color: #cc0000; }
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    function UnHide( eThis ){
        if( eThis.innerHTML.charCodeAt(0) == 9658 ){
            eThis.innerHTML = &#039;&amp;#9660;&#039;
            eThis.parentNode.parentNode.parentNode.className = &#039;&#039;;
        }else{
            eThis.innerHTML = &#039;&amp;#9658;&#039;
            eThis.parentNode.parentNode.parentNode.className = &#039;cl&#039;;
        }
        return false;
    }
&lt;/script&gt;
&lt;/head&gt;


&lt;body&gt;
&lt;div width=&quot;1800&quot; border=&quot;2&quot; align=&quot;left&quot; class=&quot;treeview&quot;&gt; &lt;!-- Начало Дерева --&gt;
    &lt;ul&gt;
        &lt;li&gt;
    &lt;div&gt;&lt;p&gt;&lt;a href=&quot;#&quot; class=&quot;sc&quot; onclick=&quot;return UnHide(this)&quot;&gt;&amp;#9660;&lt;/a&gt; &lt;B&gt;&lt;font color=&quot;red&quot; &gt;Лидер группы&lt;/font&gt;&lt;/B&gt;: № &lt;?=$row[&#039;id_user&#039;];?&gt; : &lt;?=$row[&#039;name&#039;];?&gt;;&lt;/p&gt;&lt;/div&gt;
        &lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;#&quot; class=&quot;sc&quot; onclick=&quot;return UnHide(this)&quot;&gt;&amp;#9660;&lt;/a&gt;№ и Имя того кто по ветке в право&lt;/p&gt;&lt;/div&gt; &lt;!--Правая ветка--&gt;
            &lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;#&quot; class=&quot;sc&quot; onclick=&quot;return UnHide(this)&quot;&gt;&amp;#9660;&lt;/a&gt;№ и Имя того кто по ветке в право  &lt;/p&gt;&lt;/div&gt; &lt;!--Правая ветка--&gt;
                    &lt;/ul&gt; &lt;!--Конец правых веток  следующая будет под верхней--&gt;

    &lt;li&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;#&quot; class=&quot;sc&quot; onclick=&quot;return UnHide(this)&quot;&gt;&amp;#9660;&lt;/a&gt;№ и Имя того кто по ветке вниз&lt;/p&gt;&lt;/div&gt; &lt;!--Нижняя ветка--&gt;
        &lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;#&quot; class=&quot;sc&quot; onclick=&quot;return UnHide(this)&quot;&gt;&amp;#9660;&lt;/a&gt;№ и Имя того кто по ветке в право &lt;/p&gt;&lt;/div&gt; &lt;!--Правая ветка--&gt;
&lt;/ul&gt;
        &lt;ul&gt;&lt;li&gt;&lt;div&gt;&lt;p&gt;&lt;a href=&quot;#&quot; class=&quot;sc&quot; onclick=&quot;return UnHide(this)&quot;&gt;&amp;#9660;&lt;/a&gt;№ и Имя того кто по ветке в право&lt;/p&gt;&lt;/div&gt; &lt;!--Правая ветка--&gt;
                &lt;/li&gt;
            &lt;/ul&gt;
            &lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt; 

    &lt;/body&gt;
&lt;/html&gt;</code></pre></div><p>В PMA такие ячейки: id_user , name , n_jr (это номер младшего юзера), ну и password (который нужен только для входа)<br />Задача у меня такова: <br />При входе юзера по id например 8, дерево должно выстроится по номерам младших так, чтобы №8 был лидером (он уже в &quot;корне&quot; (вверху) дерева), <br />а все младшие в иерархию один под одним опираясь на n_jr. <br />Если есть у кого то младший, то он уйдет вниз-вправо (согласно скрипта дерева в reg_index.tpl) и так сколько бы их небыло в PMA.</p><p>К примеру: id_user , name , n_jr<br />8, Федя, 15<br /> 15, Вася, 24,25<br />&nbsp; &nbsp;24, Ваня, 27, 31, 40<br />&nbsp; &nbsp; &nbsp;27, Коля, 30<br />&nbsp; &nbsp; &nbsp;31, Галя, 35<br />&nbsp; &nbsp; &nbsp;40, Люба, 44<br />&nbsp; &nbsp;25, Лёша, 49<br />...итд...</p><p>Уважаемые Гурру, помогите с задачей, googlить не выручает.<br />Вожусь и ничего сам (я новичек) придумать не могу, оч надеюсь на Вашу отзывчиврсть...</p>]]></description>
			<author><![CDATA[null@example.com (Staff93)]]></author>
			<pubDate>Wed, 08 Oct 2014 19:13:49 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=25731#p25731</guid>
		</item>
	</channel>
</rss>
