0

次の Web サイト / Web ショップについてサポートが必要です。

http://alisgfx.com/lomo/

カルーセル内のアイテムは、phpforeach を使用して配列からロードされます。私がやりたいことは、アイテムをクリックすると、index.php?product=productname という次のページに移動することです。

get variable はオプションだと思いますが、それを配列と組み合わせる方法がわかりません。どうすればこれを簡単に達成できますか?

インデックス.php

<?php
# include de benodigde bestanden (require geeft een fatale fout als het niet lukt)
require('inc/config.inc.php');
require('inc/functions.inc.php');
require('inc/template.inc.php');

# geef de HTML code voor het openen van de pagina weer
htmlOpenen('Introtekst');

toonHeader();

include 'menu.php';

?>

<!-- producten carousel -->
<section class="carousel">
    <div class="banner"><img src="img/nieuw.jpg"></div>
    <div id="slider1">
        <a class="buttons prev" href="#">left</a>
        <div class="viewport">
            <ul class="overview">
                <?php 
                foreach($nieuwBinnen as $new) {
                    echo '
                        <li>
                            <h2>'.$new['naam'].'</h2>
                            <p>'.$new['product'].'</p>
                        </li>
                    ';
                }
                ?>
            </ul>
        </div>
        <a class="buttons next" href="#">right</a>
    </div>
</section>

<section class="carousel">
    <div class="banner"><img src="img/best.jpg"></div>
    <div id="slider2">
        <a class="buttons prev" href="#">left</a>
        <div class="viewport">
            <ul class="overview">
                <?php 
                foreach($bestSellers as $bestseller) {
                    echo '
                        <li>
                            <h2>'.$bestseller['naam'].'</h2>
                            <p>'.$bestseller['product'].'</p>
                        </li>
                    ';
                }
                ?>
            </ul>
        </div>
        <a class="buttons next" href="#">right</a>
    </div>
</section>


<?php

include 'footer.php';

 ?>

関数.php

<?php 
#functies


$nieuwBinnen = array(

    array('naam'    => 'Product 1',
          'product' => 'img',
          'info'    => 'Everybody loves microcontrollers, including the Arduino, allowing you to create whatever you imagine. That is unless you want to hack together something wireless. Originally you had to rely on the expensive XBee protocol or other wireless options, but no longer. Hobby Robotics found an extremely cheap transmitter and receiver and wrote a quick guide for wiring them up to an Arduino. Now your wireless projects can come to life, as long as you are within 500 feet and don’t mind 2400bps; minor trade offs compared to the gains of wireless freedom. Final note: You aren’t limited to Arduino, we would love to see someone modify this to work with a PIC or other microcontroller.',
          'prijs'   => 'img',
          'beschik' => 'op voorraad',
          'fotos'   => 'imgs',
          'upload'  => 'imgs'),

    array('naam'    => 'Product 2',
          'product' => 'img',
          'info'    => '[Joey] sent us a link to his Gameboy foot controller. In the video above, you can see him using it to control the loops in the background while he plays his guitar through an 8-bit filter. He tells us that several gameboys were used in the construction. At one point, he had to replace the guts because the music was so loud it knocked his equipment over and destroyed it. We can’t help but feel just a tiny bit of excitement as memories of renting a NES cartridge for the weekend fill our heads when we hear these riffs. His music isn’t too bad either. There is a growing crowd of people that support “chip music”. You can see what looks like a decent sized gathering enjoying a show with a little bit of a history lesson after the break.'),

    array('naam'    => 'Product 3',
          'product' => 'img',
          'info'    => 'The Linux4nano project has been working to port the Linux kernel onto the iPod Nano along with other iPods in general. Although the iPodLinux project has had luck with some older iPods, newer models protect firmware updates with encryption. One of the ways they plan on running code on the device is through a vulnerability in the notes program; it causes the processor to jump to a specific instruction and execute arbitrary code. To take advantage of this, they first need to figure out where their injected code ends up in the memory. Currently, they are testing every memory location by painstakingly loading in a bogus note and recording its effect. Each note takes about a minute to test and they have tens of thousands of addresses to check over several devices.'),

    array('naam'    => 'Product 4',
          'product' => 'img', 
          'info'    => 'The MIT Camera Culture Group utilized Bokeh, an effect where the lens is purposely placed out of focus, in order to vastly improve current 2D barcode technology. Dubbed Bokode, the team claims that an off the shelf camera can read data 2.5 microns from a distance of over 4 meters, compared to today’s average barcode reader’s maximum distance of only a foot or so. What looks most interesting is the ability to produce a smoother and more accurate distance and angle calculations (relative to the camera): allowing for a better augmented reality. It also seems to be more secure than traditional 2D barcodes, that is of course until the hacker community gets a hold of it.'),

    array('naam'    => 'Product 5',
          'product' => 'img',
          'info'    => '[Peter Kirn] over at Create Digital Music takes an in depth look at the process of adding your own music to Rock Band 2. This involves using REAPER audio production software, uploading your work via the XNA Creators’ Club, and then playing the fresh track on an Xbox 360. Both REAPER and the XNA Club cost money, and the total price comes out somewhere between $100-$160. The process is now in closed beta but a wider beta is expected in September followed by a full release in October.')
);


$bestSellers = array(

    array('naam'    => 'Product 1',
          'product' => 'img',
          'info'    => 'Everybody loves microcontrollers, including the Arduino, allowing you to create whatever you imagine. That is unless you want to hack together something wireless. Originally you had to rely on the expensive XBee protocol or other wireless options, but no longer. Hobby Robotics found an extremely cheap transmitter and receiver and wrote a quick guide for wiring them up to an Arduino. Now your wireless projects can come to life, as long as you are within 500 feet and don’t mind 2400bps; minor trade offs compared to the gains of wireless freedom. Final note: You aren’t limited to Arduino, we would love to see someone modify this to work with a PIC or other microcontroller.'),

    array('naam'    => 'Product 2',
          'product' => 'img',
          'info'    => '[Joey] sent us a link to his Gameboy foot controller. In the video above, you can see him using it to control the loops in the background while he plays his guitar through an 8-bit filter. He tells us that several gameboys were used in the construction. At one point, he had to replace the guts because the music was so loud it knocked his equipment over and destroyed it. We can’t help but feel just a tiny bit of excitement as memories of renting a NES cartridge for the weekend fill our heads when we hear these riffs. His music isn’t too bad either. There is a growing crowd of people that support “chip music”. You can see what looks like a decent sized gathering enjoying a show with a little bit of a history lesson after the break.'),

    array('naam'    => 'Product 3',
          'product' => 'img',
          'info'    => 'The Linux4nano project has been working to port the Linux kernel onto the iPod Nano along with other iPods in general. Although the iPodLinux project has had luck with some older iPods, newer models protect firmware updates with encryption. One of the ways they plan on running code on the device is through a vulnerability in the notes program; it causes the processor to jump to a specific instruction and execute arbitrary code. To take advantage of this, they first need to figure out where their injected code ends up in the memory. Currently, they are testing every memory location by painstakingly loading in a bogus note and recording its effect. Each note takes about a minute to test and they have tens of thousands of addresses to check over several devices.'),

    array('naam'    => 'Product 4',
          'product' => 'img', 
          'info'    => 'The MIT Camera Culture Group utilized Bokeh, an effect where the lens is purposely placed out of focus, in order to vastly improve current 2D barcode technology. Dubbed Bokode, the team claims that an off the shelf camera can read data 2.5 microns from a distance of over 4 meters, compared to today’s average barcode reader’s maximum distance of only a foot or so. What looks most interesting is the ability to produce a smoother and more accurate distance and angle calculations (relative to the camera): allowing for a better augmented reality. It also seems to be more secure than traditional 2D barcodes, that is of course until the hacker community gets a hold of it.'),

    array('naam'    => 'Product 5',
          'product' => 'img',
          'info'    => '[Peter Kirn] over at Create Digital Music takes an in depth look at the process of adding your own music to Rock Band 2. This involves using REAPER audio production software, uploading your work via the XNA Creators’ Club, and then playing the fresh track on an Xbox 360. Both REAPER and the XNA Club cost money, and the total price comes out somewhere between $100-$160. The process is now in closed beta but a wider beta is expected in September followed by a full release in October.')
);

?>
4

2 に答える 2

0
            foreach($bestSellers as $bestseller) {
                echo '
                    <li>
                        <a href="index.php?product='.$bestseller['naam'].'">
                            <h2>'.$bestseller['naam'].'</h2>
                            <p>'.$bestseller['product'].'</p>
                        </a>
                    </li>
                ';
            }

製品名にスペースが含まれているという問題は別として (「Product-1」など、URL に適した識別子を使用して対処する必要があります)。上記のようなものが機能します。

于 2012-12-28T17:38:46.270 に答える
0

要素の<a href>周りにリンクを追加します-<li>

foreach($nieuwBinnen as $new) {
    echo '
        <li>
            <a href="index.php?category=new&product='.urlencode($new['naam']).'">
            <h2>'.$new['naam'].'</h2>
            <p>'.$new['product'].'</p>
            </a>
        </li>
    ';
}

foreach($bestSellers as $bestseller) {
    echo '
        <li>
            <a href="index.php?category=bestseller&product='.urlencode($bestseller['naam']).'">
            <h2>'.$bestseller['naam'].'</h2>
            <p>'.$bestseller['product'].'</p>
            </a>
        </li>
    ';
}

編集

製品が選択されているかどうかを確認し、選択されている場合は情報を表示し、選択されていない場合は製品のリストを表示します。同じ商品を持っていることに気付き$nieuwBinnenました。$bestSellersこれが常に当てはまるとは限らないためcategory=、リンクに追加して、製品を選択するアレイを選択する必要があります ( index.php?category=#&product=#)。以下はテストされていませんが、正しい方向に進むはずです。

if (isset($_GET['category']) && isset($_GET['product']) && isset($$_GET['category'])){  //display product if provided
    $category = $$_GET['category'];
    $product = $_GET['product'];
    $error_msg = 1;  //sets a basic error catcher in case product does not exist
    foreach ($category as $item) {
       if ($item['naam'] == $product) {
        echo $item['naam']."<br/>";
        echo $item['product']."<br/>";
        echo $item['info']."<br/>";
        $error = 0;
       }       
    }
 if ($error_msg){ //basic error message in case product does not exist
     echo 'The selected product no longer exists';
 } 
}          
else{  //displays all product if specific product not given
?>  
<!-- producten carousel -->
<section class="carousel">
    <div class="banner"><img src="img/nieuw.jpg"></div>
    <div id="slider1">
        <a class="buttons prev" href="#">left</a>
        <div class="viewport">
            <ul class="overview">
                <?php 
                foreach($nieuwBinnen as $new) {
                    echo '
                        <li>
                            <a href="index.php?category=nieuwBinnen&product='.urlencode($new['naam']).'">
                            <h2>'.$new['naam'].'</h2>
                            <p>'.$new['product'].'</p>
                            </a>
                        </li>
                    ';
                }
                ?>
            </ul>
        </div>
        <a class="buttons next" href="#">right</a>
    </div>
</section>

<section class="carousel">
    <div class="banner"><img src="img/best.jpg"></div>
    <div id="slider2">
        <a class="buttons prev" href="#">left</a>
        <div class="viewport">
            <ul class="overview">
                <?php 
                foreach($bestSellers as $bestseller) {
                    echo '
                        <li>
                            <a href="index.php?category=bestSellers&product='.urlencode($new['naam']).'">
                            <h2>'.$bestseller['naam'].'</h2>
                            <p>'.$bestseller['product'].'</p>
                            </a>
                        </li>
                    ';
                }
                ?>
            </ul>
        </div>
        <a class="buttons next" href="#">right</a>
    </div>
</section>
<?php
}

include 'footer.php';
?>
于 2012-12-28T17:41:11.570 に答える