Avatar billede stratokaster Novice
22. november 2007 - 12:44 Der er 6 kommentarer og
2 løsninger

Side antal 1 2 3

Hej,

Er der nogen som kan hjælpe mig med at lave et script hvor jeg får side antal vist på siden med produkter?


<?php

if (!defined('CC_INI_SET')) die("Access Denied");

// include lang file
$lang = getLang("includes".CC_DS."content".CC_DS."viewCat.inc.php");
$page = (isset($_GET['page'])) ? sanitizeVar($_GET['page']) : 0;
$view_cat = new XTemplate ("content".CC_DS."viewCat.tpl");
$view_cat->assign("LANG_DIR_LOC", $lang['viewCat']['location']);

////////////////////////
// BUILD SUB CATEGORIES
////////////////////////

if (isset($_GET['catId'])) {
    $_GET['catId'] = sanitizeVar($_GET['catId']);
    ## build query
    $emptyCat = ($config['show_empty_cat']==true) ? '' : ' AND noProducts >= 1';
    $query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_father_id = ".$db->mySQLSafe($_GET['catId'])." AND hide = 0".$emptyCat." ORDER BY priority,cat_name ASC";
   
    ## get category array in foreign innit
    $resultsForeign = $db->select("SELECT cat_master_id as cat_id, cat_name FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '" . LANG_FOLDER . "'");
   
    ## query database
    $subCategories = false;
    $subCategories = $db->select($query);
   
   
}

if (isset($_GET['catId']) && $_GET['catId']>0 && $subCategories == true) {
    ## loop results
    for ($i=0; $i<count($subCategories); $i++) {
        if (is_array($resultsForeign)) {
            for ($k=0; $k<count($resultsForeign); $k++) {
                if ($resultsForeign[$k]['cat_id'] == $subCategories[$i]['cat_id']) {
                    $subCategories[$i]['cat_name'] = $resultsForeign[$k]['cat_name'];
                }
            }
        }
       
        if (empty($subCategories[$i]['cat_image'])) {
            $view_cat->assign("IMG_CATEGORY", $GLOBALS['rootRel']."skins/". SKIN_FOLDER . "/styleImages/catnophoto.gif");
        } else {
            $view_cat->assign("IMG_CATEGORY", imgPath($subCategories[$i]['cat_image'],$thumb=0,$path="rel"));
        }
       
        $view_cat->assign("TXT_LINK_CATID",$subCategories[$i]['cat_id']);
        $view_cat->assign("TXT_CATEGORY", validHTML($subCategories[$i]['cat_name']));
        $view_cat->assign("NO_PRODUCTS", $subCategories[$i]['noProducts']);
        $view_cat->parse("view_cat.sub_cats.sub_cats_loop");
    }
    $view_cat->parse("view_cat.sub_cats");
}

////////////////////////////
// BUILD PRODUCTS
////////////////////////////


## New! Product sorting by field
$allowedSort    = array('price', 'description', 'name', 'productCode');
if (isset($_GET['sort_by']) && in_array($_GET['sort_by'], $allowedSort)) {
    switch ($_GET['sort_order']) {
        case 'high':
            $orderType = 'DESC';
            $orderText = '&uarr';
            $sortIcon = 'bullet_arrow_up.gif';
            break;
        case 'low':
            $orderType = 'ASC';
            $orderText = '&darr';
            $sortIcon = 'bullet_arrow_down.gif';
            break;
        default:
            $orderType = 'ASC';
            $sortIcon = 'bullet_arrow_down.gif';
    }
    $orderSort = sprintf(' ORDER BY %s %s', $_GET['sort_by'], $orderType);
} else {
    $orderSort = sprintf(' ORDER BY name ASC');
}

## build query
if (!empty($_REQUEST['searchStr'])) {
    /* SPIFFING NEW SEARCH FUNCTIONALITY - Version 1.1 */
    $indexes = $db->getFulltextIndex('inventory', 'I'); //array('inventory', 'inv_lang'));
       
    if (!empty($_REQUEST['priceMin']) && is_numeric($_REQUEST['priceMin'])) $where[] = sprintf("I.price >= %s", $_REQUEST['priceMin']);
    if (!empty($_REQUEST['priceMax']) && is_numeric($_REQUEST['priceMax'])) $where[] = sprintf("I.price <= %s", $_REQUEST['priceMax']);
   
    if (isset($_REQUEST['inStock'])) $where[] = "((I.useStockLevel = 0) OR (I.useStockLevel = 1 AND I.stock_level > 0))";
   
    if (!empty($_REQUEST['category'])) {
        if (is_array($_REQUEST['category'])) {
            foreach ($_REQUEST['category'] as $cat_id) {
                if (is_numeric($cat_id)) $cats[] = $cat_id;
            }
            $where[] = sprintf("I.cat_id IN (%s)", implode(',', $cats));
        } else if (is_numeric($_REQUEST['category'])) {
            $where[] = sprintf("I.cat_id = '%d'", $_REQUEST['category']);
        }
    }
   
    if (is_array($indexes)) {
       
        switch ($config['searchMode']) {
            case 'boolean':
                $mode = ' IN BOOLEAN MODE';
                break;
            case 'expansion':
                $mode = ' WITH QUERY EXPANSION';
                break;
            default:
                $mode = '';
        }
       
        if (is_array($where)) $whereString = sprintf('AND %s', implode(' AND ', $where));
       
        if (!empty($_REQUEST['searchStr'])) {
            if (!empty($orderSort)) {
                $orderSort = str_replace(' ORDER BY', '', $orderSort);
            } else {
                $orderSort = 'SearchScore DESC';
            }
            $matchString = sprintf("MATCH (%s) AGAINST(%s%s)", implode(',', $indexes), $db->mySQLsafe($_REQUEST['searchStr']), $mode);
            $search = sprintf("SELECT I.*, %2\$s AS SearchScore FROM %1\$sCubeCart_inventory AS I LEFT JOIN %1\$sCubeCart_category AS C ON C.cat_id = I.cat_id WHERE I.cat_id > 0 AND C.hide = 0 AND (%2\$s) >= %4\$f %3\$s ORDER BY %5\$s", $glob['dbprefix'], $matchString, $whereString, 0.5, $orderSort);
        } else {
            $search = sprintf("SELECT I.* FROM %sCubeCart_inventory AS I WHERE I.cat_id > 0 %s %s", $glob['dbprefix'], $whereString, $orderSort);
        }
        $productListQuery = $search;
    }
   
    $productResults = $db->select($productListQuery, $config['productPages'], $page);
   
    ## FALLBACK - If search doesn't work, try the old v3 style search
    if (!$productResults) {
        $searchwords = split ( "[ ,]", sanitizeVar($_REQUEST['searchStr'])); 
        foreach ($searchwords as $word) {
            $searchArray[] = $word;
        }
        $noKeys = count($searchArray);
       
        $like = '';
        for ($i=0; $i<$noKeys; $i++) {
            ## Uppercase the search string
            $ucSearchTerm = strtoupper($searchArray[$i]);
           
            if (($ucSearchTerm !== 'AND') && ($ucSearchTerm !== 'OR')) {
                $like .= "(name LIKE '%".$searchArray[$i]."%' OR description LIKE '%".$searchArray[$i]."%' OR productCode LIKE '%".$searchArray[$i]."%') OR ";
               
                ## See if search terrm is in database
                $searchQuery = "SELECT id FROM ".$glob['dbprefix']."CubeCart_search WHERE searchstr='".$ucSearchTerm."'";
                $searchLogs = $db->select($searchQuery);
               
                $insertStr = array(
                    'searchstr'    => $db->mySQLsafe($ucSearchTerm),
                    'hits'        => 1,
                );
                $updateStr = array(
                    'hits'        => 'hits+1',
                );
               
                if ($searchLogs) {
                    $db->update($glob['dbprefix'].'CubeCart_search', $updateStr, 'id='.$searchLogs[0]['id'], '');
               
                } else if (!empty($_REQUEST['searchStr'])) {
                    $db->insert($glob['dbprefix'].'CubeCart_search', $insertStr);
                }
               
            } else {
                $like = substr($like, 0, strlen($like)-3);
                $like .= $ucSearchTerm;
            }
        }
        $like = substr($like, 0, strlen($like)-3);
       
        $productListQuery = "SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory WHERE ".$like;
        $productResults = $db->select($productListQuery, $config['productPages'], $page);
    }
   
} else if ($_GET['catId'] == 'saleItems' && $config['saleMode']>0) {   
    $productListQuery = "SELECT ".$glob['dbprefix']."CubeCart_cats_idx.cat_id, ".$glob['dbprefix']."CubeCart_cats_idx.productId, productCode, quantity, description, image, price, name, popularity, sale_price, stock_level, useStockLevel FROM ".$glob['dbprefix']."CubeCart_cats_idx INNER JOIN ".$glob['dbprefix']."CubeCart_inventory ON ".$glob['dbprefix']."CubeCart_cats_idx.productId = ".$glob['dbprefix']."CubeCart_inventory.productId WHERE sale_price > 0 AND ".$glob['dbprefix']."CubeCart_cats_idx.cat_id > 0 GROUP BY ".$glob['dbprefix']."CubeCart_inventory.productId".$orderSort;
} else {
    $productListQuery = "SELECT ".$glob['dbprefix']."CubeCart_cats_idx.cat_id, ".$glob['dbprefix']."CubeCart_cats_idx.productId, productCode, quantity, description, image, price, name, popularity, sale_price, stock_level, useStockLevel FROM ".$glob['dbprefix']."CubeCart_cats_idx INNER JOIN ".$glob['dbprefix']."CubeCart_inventory ON ".$glob['dbprefix']."CubeCart_cats_idx.productId = ".$glob['dbprefix']."CubeCart_inventory.productId WHERE ".$glob['dbprefix']."CubeCart_cats_idx.cat_id = ".$db->mySQLSafe($_GET['catId'])." GROUP BY ".$glob['dbprefix']."CubeCart_inventory.productId".$orderSort;
}

## Run query if we haven't already done a search
if (!$productResults) {
    $productResults = $db->select($productListQuery, $config['productPages'], $page);
}

## Get different languages
if ($productResults && LANG_FOLDER !== $config['defaultLang']) {
    for ($i=0;$i<count($productResults);$i++) {
        if (($val = prodAltLang($productResults[$i]['productId'])) == true) {
            $productResults[$i]['name'] = $val['name'];
            $productResults[$i]['description'] = $val['description'];
        }
    }
}
$totalNoProducts = $db->numrows($productListQuery);

## Get current category info
if (isset($_GET['catId'])) {
    if ($config['seftags']) {
        if ($_GET['catId']>0) {
            $currentCatQuery = "SELECT cat_metatitle, cat_metadesc, cat_metakeywords, cat_name, cat_father_id, cat_id, cat_image, cat_desc FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY priority,cat_name ASC";
            $currentCat = $db->select($currentCatQuery);
           
            $prevDirSymbol = $config['dirSymbol'];
            $config['dirSymbol'] = ' - ';
            $meta['siteTitle'] = getCatDir($currentCat[0]['cat_name'],$currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], FALSE, TRUE, $config['sefprodnamefirst'] ? FALSE : TRUE);
            $config['dirSymbol'] = $prevDirSymbol;

            $meta['metaDescription'] = strip_tags($config['metaDescription']);       
            $meta['sefSiteTitle'] = $currentCat[0]['cat_metatitle'];
            $meta['sefSiteDesc'] = $currentCat[0]['cat_metadesc'];
            $meta['sefSiteKeywords'] = $currentCat[0]['cat_metakeywords'];
           
        } else if (strcmp($_GET['catId'], "saleItems") == 0) {
            $meta['siteTitle'] = $lang['front']['boxes']['sale_items'];
            $meta['metaDescription'] = strip_tags($config['metaDescription']);
        }
    } else if (is_numeric($_GET['catId'])) {
        $currentCatQuery = "SELECT cat_name, cat_father_id, cat_id, cat_image, cat_desc FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_id = ".$db->mySQLSafe($_GET['catId'])." ORDER BY priority,cat_name ASC";
        $currentCat = $db->select($currentCatQuery);
    }
   
    # Get translations
    $resultForeign = $db->select("SELECT cat_master_id as cat_id, cat_name, cat_desc FROM ".$glob['dbprefix']."CubeCart_cats_lang WHERE cat_lang = '".LANG_FOLDER."' AND cat_master_id = ".$db->mySQLSafe($_GET['catId']));
    if ($resultForeign == true) {
        $currentCat[0]['cat_name'] = $resultForeign[0]['cat_name'];
        $currentCat[0]['cat_desc'] = $resultForeign[0]['cat_desc'];
    }
}

if (!empty($currentCat[0]['cat_image'])) {
    $view_cat->assign("IMG_CURENT_CATEGORY",imgPath($currentCat[0]['cat_image'],$thumb=0,$path="rel"));
    $view_cat->assign("TXT_CURENT_CATEGORY",validHTML($currentCat[0]['cat_name']));
    $view_cat->parse("view_cat.cat_img");
}

if (isset($_REQUEST['searchStr'])) {
    $view_cat->assign("TXT_CAT_TITLE", $lang['viewCat']['search_results']);
    $view_cat->assign("CURRENT_LOC", $config['dirSymbol'].$lang['viewCat']['search_results']);
} else if ($_GET['catId']=="saleItems" && $config['saleMode']>0) {
    $view_cat->assign("TXT_CAT_TITLE", $lang['viewCat']['sale_items']);
    $view_cat->assign("CURRENT_LOC", $config['dirSymbol'].$lang['viewCat']['sale_items']);
} else {
    $view_cat->assign("TXT_CAT_TITLE", validHTML($currentCat[0]['cat_name']));
    $view_cat->assign("CURRENT_LOC", getCatDir($currentCat[0]['cat_name'], $currentCat[0]['cat_father_id'], $currentCat[0]['cat_id'], $link=true));
}
   
if (!empty($currentCat[0]['cat_desc'])) {
    $view_cat->assign("TXT_CAT_DESC", $currentCat[0]['cat_desc']);
    $view_cat->parse("view_cat.cat_desc");
}
   
$view_cat->assign("LANG_IMAGE", $lang['viewCat']['image']);
$view_cat->assign("LANG_DESC", $lang['viewCat']['description']);
$view_cat->assign("LANG_NAME", $lang['viewCat']['name']);
$view_cat->assign("LANG_PRICE", $lang['viewCat']['price']);
   
$pagination = paginate($totalNoProducts, $config['productPages'], $page, "page");
   
if (!empty($pagination)) {
    $view_cat->assign("PAGINATION", $pagination);
    $view_cat->parse("view_cat.pagination_top");
    $view_cat->parse("view_cat.pagination_bot");
}
   
## create the links for product sorting - need improving later
$sort_order =  ($_GET['sort_order'] == 'high') ? 'low' : 'high';
switch($_GET['sort_by']) {
    case 'name':
        $view_cat->assign('SORT_NAME_SELECTED', ' selected="selected"');
        break;
    case 'price':
        $view_cat->assign('SORT_PRICE_SELECTED', ' selected="selected"');
        break;
}

#    $view_cat->assign('SORT_DIRECTION_TEXT', $orderText);
unset($_GET['sort_by'], $_GET['sort_order']);

$view_cat->assign('SORT_PROD_CODE', currentPage()."&amp;sort_by=productCode&amp;sort_order=".$sort_order);
$view_cat->assign('SORT_PRICE', currentPage()."&amp;sort_by=price&amp;sort_order=".$sort_order);
$view_cat->assign('SORT_DESC', currentPage()."&amp;sort_by=description&amp;sort_order=".$sort_order);
$view_cat->assign('SORT_NAME', currentPage()."&amp;sort_by=name&amp;sort_order=".$sort_order);
if (!empty($sortIcon) && file_exists('skins'.CC_DS.SKIN_FOLDER.CC_DS.'styleImages'.CC_DS.'icons'.CC_DS.$sortIcon)) {
    $view_cat->assign('SORT_ICON', sprintf('<img src="%s", alt="" />', 'skins'.CC_DS.SKIN_FOLDER.CC_DS.'styleImages'.CC_DS.'icons'.CC_DS.$sortIcon));
}
   
## repeated region
if ($productResults) {
    for ($i=0; $i<count($productResults); $i++) {
        ## alternate class
        $view_cat->assign("CLASS",cellColor($i, $tdEven="tdEven", $tdOdd="tdOdd"));

        $thumbRoot = imgPath($productResults[$i]['image'], $thumb=1, $path="root");
        $thumbRootRel = imgPath($productResults[$i]['image'], $thumb=1, $path="rel");
       
        if (file_exists($thumbRoot)) {
            $view_cat->assign("SRC_PROD_THUMB", $thumbRootRel);
        } else {
            $view_cat->assign("SRC_PROD_THUMB", $GLOBALS['rootRel']."skins/". SKIN_FOLDER . "/styleImages/thumb_nophoto.gif");
        }

        $view_cat->assign("TXT_TITLE", validHTML($productResults[$i]['name']));
       
        if (strlen($productResults[$i]['description']) > $config['productPrecis']) {
            $view_cat->assign("TXT_DESC", substr(strip_tags($productResults[$i]['description']), 0, $config['productPrecis'])."&hellip;");
        } else {
            $view_cat->assign("TXT_DESC", $productResults[$i]['description']);
        }

        if (salePrice($productResults[$i]['price'], $productResults[$i]['sale_price']) == false) {
            $view_cat->assign("TXT_PRICE", priceFormat($productResults[$i]['price'], true));
        } else {
            $view_cat->assign("TXT_PRICE","<span class='txtOldPrice'>".priceFormat($productResults[$i]['price'],true)."</span>");
        }
        $salePrice = salePrice($productResults[$i]['price'], $productResults[$i]['sale_price']);
       
        $view_cat->assign("TXT_SALE_PRICE", priceFormat($salePrice,true));

        if (isset($_GET['add']) && isset($_GET['quan'])) {
            $view_cat->assign("CURRENT_URL", str_replace(array("&amp;add=".$_GET['add'], "&amp;quan=".$_GET['quan']), '', currentPage()));
           
        } else {
            $view_cat->assign("CURRENT_URL", currentPage());
        }

        if ($config['outofstockPurchase'] == true) {
            $view_cat->assign("BTN_BUY", $lang['viewCat']['buy']);
            $view_cat->assign("PRODUCT_ID", $productResults[$i]['productId']);
            $view_cat->parse("view_cat.productTable.products.buy_btn");
       
        } else if ($productResults[$i]['useStockLevel'] == true && $productResults[$i]['stock_level']>0) {
            $view_cat->assign("BTN_BUY", $lang['viewCat']['buy']);
            $view_cat->assign("PRODUCT_ID", $productResults[$i]['productId']);
            $view_cat->parse("view_cat.productTable.products.buy_btn");
       
        } else if ($productResults[$i]['useStockLevel'] == false) {
            $view_cat->assign("BTN_BUY", $lang['viewCat']['buy']);
            $view_cat->assign("PRODUCT_ID", $productResults[$i]['productId']);
            $view_cat->parse("view_cat.productTable.products.buy_btn");
        }

        $view_cat->assign("BTN_MORE", $lang['viewCat']['more']);
        $view_cat->assign("PRODUCT_ID", $productResults[$i]['productId']);

        if ($productResults[$i]['stock_level']<1 && $productResults[$i]['useStockLevel'] == true && $productResults[$i]['digital'] == false) {
            $view_cat->assign("TXT_OUTOFSTOCK", $lang['viewCat']['out_of_stock']);
        } else {
            $view_cat->assign("TXT_OUTOFSTOCK", '');
        }
       
        $view_cat->parse("view_cat.productTable.products");
    }
   
    $view_cat->assign("LANG_SORT", $lang['viewCat']['sort']);
    $view_cat->parse("view_cat.productTable");
   
} else if (!$productResults && isset($_REQUEST['searchStr'])) {
    $view_cat->assign("TXT_NO_PRODUCTS", sprintf($lang['viewCat']['no_products_match'], sanitizeVar($_REQUEST['searchStr'])));
    $view_cat->parse("view_cat.noProducts");

} else {
    $view_cat->assign("TXT_NO_PRODUCTS", $lang['viewCat']['no_prods_in_cat']);
    $view_cat->parse("view_cat.noProducts");
}

$view_cat->parse("view_cat");
$page_content = $view_cat->text("view_cat");



?>
Avatar billede kbirk Nybegynder
23. november 2007 - 23:34 #1
Du kan bruge LIMIT til at få et bestemt antal records ud ad gangen.
SELECT * FROM tbl LIMIT 5,10;

Eks:
ANTAL_PER_SIDE = 20
SIDE_ANTAL = 3

SELECT * FROM tbl LIMIT SIDE_ANTAL*ANTAL_PER_SIDE,(SIDE_ANTAL*ANTAL_PER_SIDE)+;
Avatar billede kbirk Nybegynder
23. november 2007 - 23:36 #2
Hovsa

Eks:
ANTAL_PER_SIDE = 20
SIDE_ANTAL = 3

SELECT * FROM tbl LIMIT SIDE_ANTAL*ANTAL_PER_SIDE,(SIDE_ANTAL*ANTAL_PER_SIDE)+ANTAL_PER_SIDE;
Avatar billede stratokaster Novice
24. november 2007 - 10:27 #3
hvor skal jeg putte koden henne har prøvet forskellige steder men får fejl?
Avatar billede kbirk Nybegynder
24. november 2007 - 13:52 #4
Det var kun et eksempel jeg skrev.
Jeg kan ikke lige fortælle dig hvor de skal tilføje koden, for du skal nok lave lidt mere end det jeg har skrevet. Prøv at finde ud af hvor du henter dine produkter ind på siden, og så tilføj limit i din sql. Derefter skal du lave en optælling af produkter ialt, og beregne hvor mange sider det er ialt. Når du har fundet ud af det skriver du sidenumrene ud til HTML/skærmen. Prøv at skriv igen når du har gjort det..
Avatar billede stratokaster Novice
24. november 2007 - 14:32 #5
Har prøvet at putte det ind her men får stadigvæk error


   
        ## start limit if $maxRows is greater than 0
       
       
        SELECT * FROM tbl LIMIT SIDE_ANTAL*ANTAL_PER_SIDE,(SIDE_ANTAL*ANTAL_PER_SIDE)+ANTAL_PER_SIDE;
       
        if ($maxRows > 0) {
            $startRow = $pageNum * $maxRows;
            $query = sprintf("%s LIMIT %d, %d", $query, $startRow, $maxRows);
        }   
        $result = mysql_query($query);
       
        if ($this->error()) die ($this->debug());
               
        if (mysql_num_rows($result) >= 1) {
            for ($n=0; $n < mysql_num_rows($result); $n++) {
                $row = mysql_fetch_assoc($result);
                $output[$n] = $row;
            }
            return $output;
        } else {
            return false;
        }
    }
   
    function misc($query, $debug = true) {
        $this->query = $query;
        $result = mysql_query($query);
        if ($this->error() && $debug == true) die ($this->debug());
        return ($result) ? true : false;
    }
   
    function numrows($query) {
        $this->query = $query;
        $result = mysql_query($query);
        return mysql_num_rows($result);
    }
   
    function getRows($query) {
        $this->query = $query;
        $result = mysql_query($query);
        $tables = array();
        while ($row = mysql_fetch_row($result)) {
            $tables[] = $row;
        }
        return $tables;
    }
   
    function insert($tablename, $record) {
        if (!is_array($record)) die($this->debug("array", "Insert", $tablename));
       
        foreach ($record as $field => $value) {
            $fields[] = sprintf("`%s`", $field);
            $values[] = sprintf("%s", $value);
        }
       
        $this->query = sprintf("INSERT INTO %s (%s) VALUES (%s);", $tablename, implode(',', $fields), implode(',', $values));
        mysql_query($this->query);
        if ($this->error()) die ($this->debug());
        return ($this->affected() > 0) ? true : false;
    }
   
    function update($tablename, $record, $where = '') {
        if(!is_array($record)) die ($this->debug("array", "Update", $tablename));
   
        foreach ($record as $field => $value) {
            $set[] = sprintf("`%s` = %s", $field, $value);
        }
       
        if(!empty($where)) {
            if (is_array($where)) {
                foreach ($where as $field => $value) {
                    $whereArray[] = sprintf("`%s` = '%s'", $field, $value);
                }
                $where = "WHERE ".implode(' AND ', $whereArray);
            } else {
                $where = "WHERE ".$where;
            }
        }
       
        $this->query = sprintf("UPDATE %s SET %s %s;", $tablename, implode(',', $set), $where);
        mysql_query($this->query);
        if ($this->error()) die ($this->debug());
        return ($this->affected() > 0) ? true : false;
       
    }
   
    function categoryNos($cat_id, $sign, $amount = 1) {
        global $glob;
        if ($cat_id > 0) {
            do {
                $record['noProducts'] = " noProducts ".$sign.$amount;
                $where = "cat_id = ".$cat_id;
                $this->update($glob['dbprefix']."CubeCart_category", $record, $where, "");
                $query = "SELECT cat_father_id FROM ".$glob['dbprefix']."CubeCart_category WHERE cat_id = ".$cat_id;
                $cfi = $this->select($query);
                $cat_id = $cfi['0']['cat_father_id'];
            }
            while ($cat_id > 0);
        }
    }
   
    function delete($tablename, $where, $limit = '') {
       
        $query = "DELETE from ".$tablename." WHERE ".$where;
        if (!empty($limit)) $query .= " LIMIT " . $limit;
       
        $this->query = $query;
        mysql_query($query);
       
        if ($this->error()) die ($this->debug());
        return ($this->affected() > 0) ? true : false;
    }
   
    function truncate($tablename) {
        $this->query = sprintf('TRUNCATE %s;', $tablename);
        mysql_query($this->query);
        if ($this->error()) die ($this->debug());
    }
Avatar billede kbirk Nybegynder
24. november 2007 - 19:02 #6
Hmm.. du kan ikke bare putte det ind i din kode.. SELECT * FROM tbl LIMIT SIDE_ANTAL*ANTAL_PER_SIDE,(SIDE_ANTAL*ANTAL_PER_SIDE)+ANTAL_PER_SIDE; vil give en fejl.. Du skal nok læse lidt om PHP før du begiver dig ud i det her projekt tror jeg..
Her er lidt inspiration til hvordan mySql virker, og hvordan du bruger databasen med php:
http://www.udvikleren.dk/PHP/Article.aspx/61/
http://www.udvikleren.dk/PHP/Article.aspx/64/
Avatar billede stratokaster Novice
24. november 2007 - 20:33 #7
Havde håbet på at få et script som virkede,tror ikke jeg får så meget ud af at læse artiklerne!
Avatar billede kbirk Nybegynder
24. november 2007 - 23:41 #8
Men hvor har du din nuværende kode fra..? Virker den som den er nu..? Jeg tror der er en del arbejde i at få det til at virke..
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB

Politiets Efterretningstjeneste

IT-frontdesk medarbejder til PET's IT Servicedesk

Forsvarsministeriets Materiel- og Indkøbsstyrelse

Sektionschef til Cyber Security Guidance ved Cyberdivisionen i Forsvaret

Udlændinge- og Integrationsministeriet

Contract manager til it-området i Udlændingestyrelsen

Forsvarsministeriets Materiel- og Indkøbsstyrelse

Ingeniør til Satellitkommunikation