[ create a new paste ] login | about

Link: http://codepad.org/YnafFVP4    [ raw code | output | fork ]

PHP, pasted on Oct 1:
<?php

// Example Filter
$_GET['filter'] = 'blue and green';

$data = array(
"1" => array("red", "black", "blue and green"),
"2" => array("orange"),
"3" => array("silver", "gold"),
"4" => array("pruple"),
"5" => array("pink", "yellow"),
"6" => array("black")
);
?>
/*#######################################
 No more edits DO NOT EDIT FURTHER
#######################################*/?>
<?php foreach ($data as $key => $array): ?>
<div class="item" id="item_<?= $key ?>">
    <div class="itemdata">
    <?php foreach ($array as $row): ?>
        <?php if ($row == $_GET['filter']): ?>
            <a href="/products/<?=$row?>"><img src="/products/<?=$row?>.jpg" /></a>
        <?php endif; ?>
    <?php endforeach ?>
    </div>
</div>
<?php endforeach ?>


Output:
/*#######################################
 No more edits DO NOT EDIT FURTHER
#######################################*/?>
<div class="item" id="item_1">
    <div class="itemdata">
                                                <a href="/products/blue and green"><img src="/products/blue and green.jpg" /></a>
                </div>
</div>
<div class="item" id="item_2">
    <div class="itemdata">
                    </div>
</div>
<div class="item" id="item_3">
    <div class="itemdata">
                                </div>
</div>
<div class="item" id="item_4">
    <div class="itemdata">
                    </div>
</div>
<div class="item" id="item_5">
    <div class="itemdata">
                                </div>
</div>
<div class="item" id="item_6">
    <div class="itemdata">
                    </div>
</div>


Create a new paste based on this one


Comments: