All pastes #249090 Raw Edit

Unnamed

public php v1 · immutable
#249090 ·published 2006-11-15 12:21 UTC
rendered paste body
<?   // ---- CATEGORIES   function tep_show_category($counter) {    global $tree, $categories_string, $cPath_array;    if(!$tree[$counter]['level']){                    $categories_string .= $categories_string ? '<tr><td background=images/m24.gif height=1></td></tr>' : '';                  $categories_string .= '<tr><td height=22><a class=ml2 href=';     if ($tree[$counter]['parent'] == 0) {      $cPath_new = 'cPath=' . $counter;    } else {      $cPath_new = 'cPath=' . $tree[$counter]['path'];    }    $categories_string .= tep_href_link('index.php', $cPath_new) . '>';// display categry name    $categories_string .= $tree[$counter]['name'];    $categories_string .= '</a></td></tr>';    }else{  // SUBCATEGORY     $categories_string .= '<tr><td height=22>';//problematique bugs ici ///////////////////////////BY HEADMAX////////////////////////////////    for($i=0;$i<$tree[$counter]['level'];$i++)     $categories_string .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';     $categories_string .= '&nbsp;&nbsp;&nbsp;  <a class=ml2 style="font-weight:normal;" href=';       if ($tree[$counter]['parent'] == 0) {      $cPath_new = 'cPath=' . $counter;    } else {      $cPath_new = 'cPath=' . $tree[$counter]['path'];    }    $categories_string .= tep_href_link('index.php', $cPath_new) . '>-';// display category name    $categories_string .= $tree[$counter]['name'];    $categories_string .= '</a></td></tr>';   }       if ($tree[$counter]['next_id'] != false) {      tep_show_category($tree[$counter]['next_id']);    }    }     define(TABLE_CATEGORIES, "categories");  define(TABLE_CATEGORIES_DESCRIPTION, "categories_description");  $categories_string = '';  $tree = array();   $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");  while ($categories = tep_db_fetch_array($categories_query))  {    $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],                                                'parent' => $categories['parent_id'],                                                'level' => 0,                                                'path' => $categories['categories_id'],                                                'next_id' => false);     if (isset($parent_id)) {      $tree[$parent_id]['next_id'] = $categories['categories_id'];    }     $parent_id = $categories['categories_id'];     if (!isset($first_element)) {      $first_element = $categories['categories_id'];    }  }   //------------------------  if ($cPath) {    $new_path = '';    reset($cPath_array);    while (list($key, $value) = each($cPath_array)) {      unset($parent_id);      unset($first_id);      $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");      if (tep_db_num_rows($categories_query)) {        $new_path .= $value;        while ($row = tep_db_fetch_array($categories_query)) {          $tree[$row['categories_id']] = array('name' => $row['categories_name'],                                               'parent' => $row['parent_id'],                                               'level' => $key+1,                                               'path' => $new_path . '_' . $row['categories_id'],                                               'next_id' => false);           if (isset($parent_id)) {            $tree[$parent_id]['next_id'] = $row['categories_id'];          }           $parent_id = $row['categories_id'];           if (!isset($first_id)) {            $first_id = $row['categories_id'];          }           $last_id = $row['categories_id'];        }        $tree[$last_id]['next_id'] = $tree[$value]['next_id'];        $tree[$value]['next_id'] = $first_id;        $new_path .= '_';      } else {        break;      }    }  }  $categories_string .=  '';  tep_show_category($first_element);   $categories_string .=  '';   echo $categories_string; ?>   page qui contient la requete qui va recuperer les parametres GET URL pour affiché les catégories et sous catégories. <?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);   switch ($theType) {    case "text":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;        case "long":    case "int":      $theValue = ($theValue != "") ? intval($theValue) : "NULL";      break;    case "double":      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";      break;    case "date":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;    case "defined":      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;      break;  }  return $theValue;}}  $colname_Recordset1 = "1";if (isset($_GET['cPath'])) {  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['cPath'] : addslashes($_GET['cPath']);}$colname1_Recordset1 = "1";if (isset($_GET['cRoot'])) {  $colname1_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['cRoot'] : addslashes($_GET['cRoot']);}mysql_select_db($database_conn, $conn);$query_Recordset1 = sprintf("SELECT * FROM categories p LEFT JOIN categories_description m ON p.categories_id = m.categories_id WHERE p.categories_id = %s AND p.parent_id = %s", GetSQLValueString($colname_Recordset1, "int"),GetSQLValueString($colname1_Recordset1, "int"));$Recordset1 = mysql_query($query_Recordset1, $conn) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);?>