News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1192807680:v:use_geshi-1:v:type-php

Started by Guest, Oct 19, 2007, 03:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Guest

global $db_prefix, $scripturl;

$query = db_query(\"SELECT id, value1, value2
     FROM {$db_prefix}tp_variables
     WHERE type = \'category\'
     ORDER BY value2\", __FILE__, __LINE__);

echo \'<div class=\"mediumtext\" style=\"overflow: auto; width: 100%;\">\';

while ($row = mysql_fetch_assoc($query)){
   

   
}

Guest

global $db_prefix, $scripturl;

$query = db_query(\"SELECT id, value1, value2
     FROM {$db_prefix}tp_variables
     WHERE type = \'category\'
     ORDER BY value2\", __FILE__, __LINE__);

echo \'<div class=\"mediumtext\" style=\"overflow: auto; width: 100%;\">\';

while ($row = mysql_fetch_assoc($query)){
   

   
}

Guest

global $db_prefix, $scripturl;

$query = db_query("SELECT id, value1, value2
     FROM {$db_prefix}tp_variables
     WHERE type = 'category'
     ORDER BY value2", __FILE__, __LINE__);

echo '<div class="mediumtext" style="overflow: auto; width: 100%;">';

while ($row = mysql_fetch_assoc($query)){
   

   
}

Guest

global $db_prefix, $scripturl;

$query = db_query("SELECT id, value1, value2
              FROM {$db_prefix}tp_variables
               WHERE type = 'category'", __FILE__, __LINE__);

echo '<div class="mediumtext" style="overflow: auto; width: 100%;">';

while ($row = mysql_fetch_assoc($query)){
   if ($row['value2'] == 0){
      echo '<a href="' . $scripturl . '?cat=' . $row['id'] . '">' . $row['value1'] . '</a>
';
   }
   else{
      $query2 = db_query("SELECT id, value1, value2
               FROM {$db_query}tp_variables
               WHERE type = 'category'
               AND value2 = $row['id']", __FILE__, __LINE__);
      
      while ($cat = mysql_fetch_assoc($query2)){
         echo '&nbsp;&nbsp;<a href="' . $scripturl . '?cat=' . $cat['id'] . '">' . $cat['value1'] . '</a>
';
      }
   }    
}
echo '</div>';

Guest

global $db_prefix, $scripturl;

$query = db_query("SELECT id, value1, value2
              FROM {$db_prefix}tp_variables
               WHERE type = 'category'", __FILE__, __LINE__);

echo '<div class="mediumtext" style="overflow: auto; width: 100%;">';

while ($row = mysql_fetch_assoc($query)){
   if ($row['value2'] == 0){
      echo '<a href="' . $scripturl . '?cat=' . $row['id'] . '">' . $row['value1'] . '</a>
';
   }
   else{
      $query2 = db_query("SELECT id, value1, value2
               FROM {$db_query}tp_variables
               WHERE type = 'category'
               AND value2 = $row['id']", __FILE__, __LINE__);
      
      while ($cat = mysql_fetch_assoc($query2)){
         echo '  <a href="' . $scripturl . '?cat=' . $cat['id'] . '">' . $cat['value1'] . '</a>
';
      }
   }    
}
echo '</div>';

Guest

global $db_prefix, $scripturl;

$query = db_query("SELECT id, value1, value2
     FROM {$db_prefix}tp_variables
     WHERE type = 'category'", __FILE__, __LINE__);

echo '<div class="mediumtext" style="overflow: auto; width: 100%;">';

while ($row = mysql_fetch_assoc($query)){
   if ($row['value2'] == 0){
      echo '<a href="' . $scripturl . '?cat=' . $row['id'] . '">' . $row['value1'] . '</a>
';
   }
   else{
      $query2 = db_query("SELECT id, value1, value2
          FROM {$db_query}tp_variables
          WHERE type = 'category'
          AND value2 = $row['id']", __FILE__, __LINE__);
      
      while ($cat = mysql_fetch_assoc($query2)){
         echo '  <a href="' . $scripturl . '?cat=' . $cat['id'] . '">' . $cat['value1'] . '</a>
';
      }
   }    
}
echo '</div>';

Guest

<?php
global $db_prefix, $scripturl;

$request = db_query("
   SELECT id, value1, value2
        FROM {$db_prefix}tp_variables
        WHERE type = 'category'", __FILE__, __LINE__);

$links = array();
while ($row = mysql_fetch_assoc($request))
{
   // It's a parent.
   if (empty($row['value2']))
      $links[$row['id']] = array(
         'id' => $row['id'],
         'name' => $row['value1'],
         'link' => '<a href="' . $scripturl . '?cat=' . $row['id'] . '">' . $row['value1'] . '</a>',
         'children' => array()
      );
   elseif (isset($links[$row['value2']]))
      $links[$row['value2']]['children'][$row['id']] = array(
         'id' => $row['id'],
         'name' => $row['value1'],
         'link' => '<a href="' . $scripturl . '?cat=' . $row['id'] . '">' . $row['value1'] . '</a>',
      );  
}
mysql_free_result($request);

echo '
<div class="mediumtext" style="overflow: auto; width: 100%;">
   <ul>';

// Loop through the array.
foreach ($links as $link)
{
   if (empty($link['children']))
      echo '
      <li>', $link['link'], '</li>';
   else
   {
      echo '
      <li>', $link['link'], '
         <ul>';

      // Children.
      foreach ($link['children'] as $child)
         echo '
            <li>', $child['link'], '</li>';

      echo '
         </ul>
      </li>';
   }
}
echo '
   </ul>
</div>';
?>