私はPHPコードでいくつかの助けが必要です。例えば、以上のproduct_id + 15を必要とする状況があるので、私は、これは無限作ることができるどのようPHPで無限にする場合
$rsNext = $this->model_catalog_product->getProduct($product_id+1);
$rsNext2 = $this->model_catalog_product->getProduct($product_id+2);
$rsNext3 = $this->model_catalog_product->getProduct($product_id+3);
$rsLast = $this->model_catalog_product->getProduct($product_id-1);
$rsLast2 = $this->model_catalog_product->getProduct($product_id-2);
$rsLast3 = $this->model_catalog_product->getProduct($product_id-3);
if($rsNext):
$this->data['next_url'] = $this->url->link('product/product', 'product_id=' . $rsNext['product_id']);
$this->data['next_text']= $rsNext['name']." >>";
elseif($rsNext2):
$this->data['next_url'] = $this->url->link('product/product', 'product_id=' . $rsNext2['product_id']);
$this->data['next_text']= $rsNext2['name']." >>";
elseif($rsNext3):
$this->data['next_url'] = $this->url->link('product/product', 'product_id=' . $rsNext3['product_id']);
$this->data['next_text']= $rsNext3['name']." >>";
else:
$this->data['next_url'] = '';
$this->data['next_text']= '';
endif;
if($rsLast):
$this->data['prev_url'] = $this->url->link('product/product', 'product_id=' . $rsLast['product_id']);
$this->data['prev_text']= "<< ".$rsLast['name'];
elseif($rsLast2):
$this->data['prev_url'] = $this->url->link('product/product', 'product_id=' . $rsLast2['product_id']);
$this->data['prev_text']= "<< ".$rsLast2['name'];
elseif($rsLast3):
$this->data['prev_url'] = $this->url->link('product/product', 'product_id=' . $rsLast3['product_id']);
$this->data['prev_text']= "<< ".$rsLast3['name'];
else:
$this->data['prev_url'] = '';
$this->data['prev_text']= null;
endif;
: は、私は私のコントローラ/製品/ product.phpに(opencart 1.5.6)にこのコードを持っています。 ありがとう!
無限を使用してforeachの
基本的な例を使ってlooppを作りますか?これは、コードを実行するのに無限の時間を要します。ループを使うのはどうですか? – Xorifelse
これは私が欲しいものですが、どのようにループを作りますか?ループを作れば、これは私のロードスピードに影響しますか? –
whileやforeachを使ってループを作る –