Síða 1 af 1

Smá svona fyrir svefn ;)(PHP beware)

Sent: Mið 14. Sep 2011 01:05
af Athena.V8
Lítil sölusíða Hönnuð til að vera Iframe ebedduð á annari síðu

Legend:

ID = Ef þetta er sett þá sýnir hann bara þetta id flott fyrir 1X dálk á bloggi TD
W = Stjórnar wíddini
NoDetail= Ef þetta er EKKI sett sýnir hann upplýsingar um seljanda
NoHeader= Ef þetta er EKKI sett þá sýnir hann Headerinn fyrir töfluna - Verð desc price


Þetta er the most basic dæmi
shopper.php?id=1&NoDetail=1&NoHeader=1&W=500

Í náinni framtíð þá mun ég klára svona control panel
Og bjóða uppá þína eigin síðu (Users)

Kóði: Velja allt

<?php
class Item
{
   private $Price;
   private $Name;
   private $Descr;
   function __Construct($TPrice,$TName,$TDescr)
   {
      $this->Price = $TPrice;
      $this->Name = $TName;
      $this->Descr = $TDescr;
   }
   function Fetch()
   {
      return'
      <tr style="height:80px;">
      <td width="120px">'. $this->Name.'</td><td colspan="2" width="100px">'. $this->Descr .'</td><td style="width:50px;">'. $this->Price .'</td><td MouseEnabled="1"><a  href="./Contact.php?id='. $this->Name .'">Versla</a></td>
      </tr>
      ';
   }
}
if(isset($_GET['id']))
{

include "simple_html_dom.php";
$html = file_get_html('./XML/master.XML');
$OwnerName = $html->find('Shop ShopKeeper Name',0);
$OwnerEmail = $html->find('Shop ShopKeeper Email',0);
$Products = array();
foreach($html->find('Shop Stock Item') as $element)
{
    $TID = $element->children(3)->plaintext;
    if($TID == $_GET['id'])
    {
        $TName = $element->children(0)->plaintext;
        $TPrice = $element->children(2)->plaintext;
        $TDescr = $element->children(1)->plaintext;
        $TempClass = new Item($TPrice,$TName,$TDescr);
        array_push($Products,$TempClass);
    }
}
}
?>


<?php
if(!isset($_GET['id']))
{
include "simple_html_dom.php";
$html = file_get_html('./XML/master.XML');
$OwnerName = $html->find('Shop ShopKeeper Name',0);
$OwnerEmail = $html->find('Shop ShopKeeper Email',0);
$Products = array();
foreach($html->find('Shop Stock Item') as $element)
{
    $TName = $element->children(0)->plaintext;
    $TPrice = $element->children(2)->plaintext;
    $TDescr = $element->children(1)->plaintext;
   $TempClass = new Item($TPrice,$TName,$TDescr);
    array_push($Products,$TempClass);
}

}
?>

<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <title>jQuery UI Example Page</title>
      <link type="text/css" href="http://jqueryui.com/themes/base/jquery.ui.all.css" rel="stylesheet" />
        <style type="text/css">
            .styleTable { border-collapse: separate; }
            .styleTable TD { font-weight: normal !important; padding: .4em; border-top-width: 0px !important; }
            .styleTable TH { text-align: center; padding: .8em .4em; }
            .styleTable TD.first, .styleTable TH.first { border-left-width: 0px !important; }
        </style>
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
      <script type="text/javascript" src="http://code.jquery.com/ui/1.8.13/jquery-ui.min.js"></script>
        <script type="text/javascript">

    (function ($) {
        $.fn.styleTable = function (options) {
            var defaults = {
                css: 'styleTable'
            };
            options = $.extend(defaults, options);

            return this.each(function () {

                input = $(this);
                input.addClass(options.css);

                input.find("tr").live('mouseover mouseout', function (event) {
                    if (event.type == 'mouseover') {
                        $(this).children("td[MouseEnabled=1]").addClass("ui-state-hover");
                    } else {
                        $(this).children("td[MouseEnabled=1]").removeClass("ui-state-hover");
                    }
                });

                input.find("th").addClass("ui-state-default");
                input.find("td").addClass("ui-widget-content");

                input.find("tr").each(function () {
                    $(this).children("td:not(:first)").addClass("first");
                    $(this).children("th:not(:first)").addClass("first");
                });
            });
        };
    })(jQuery);

    $(document).ready(function () {
        $("#Table1").styleTable();
    });

</script>
   </head>
   <body>
         <table width="<?php if(!isset($_GET['W'])){ echo'700px';}else{echo $_GET['W'];} ?>" height="100%" style="word-wrap:break-word;" border="0" cellspacing="0" cellpadding="0" id="Table1">
                <?php
                if(!isset($_GET['NoDetail']))
                {
                echo'
            <tr>
               <th style="Width:180px;" colspan="2">ShopOwner</th><th colspan="3">OwnerEmail</th>
            </tr>
            <tr>
               <td style="Width:180px;" colspan="2">'. $OwnerName .'</td><td colspan="3">'.$OwnerEmail .'</td>
            </tr>
                ';}
                if(!isset($_GET['NoHeader']))
                {
                echo'<tr><th style="Width:180px;">Nafn</th><th colspan="3">Lýsing</th><th width="40px">Verð</th></tr>';
                }
                ?>
                <?php
                foreach($Products as $element)
                {
                echo $element->Fetch();
                }
                ?>
         </table>
   </body>
</html>


Ogso XML fællin ./XML/master.XML

Kóði: Velja allt

<Shop>

    <ShopKeeper>
        <Name>Athena.V8</Name>
        <Email>Athena.V8@Gmail.com</Email>
    </ShopKeeper>
    <Stock>
        <Item>
            <Name>Tolva 1</Name>
            <Description>Þetta er tölva fuckers</Description>
            <Price>150Þ</Price>
            <ID>1</ID>
        </Item>
        <Item>
            <Name>Tolva 1</Name>
            <Description>Þetta er tölva fuckers</Description>
            <Price>150Þ</Price>
            <ID>2</ID>
        </Item>
        <Item>
            <Name>Length Test12348976543</Name>
            <Description>Þetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTrollÞetta er tölva fuckersTrollTrollTrollTrollTrollTrollTrollTrollTroll</Description>
            <Price>150222Þ</Price>
            <ID>3</ID>
        </Item>
        <Item>
            <Name>Realistic sample</Name>
            <Description>Þetta er Prentari Pixma ip 2700 Hann er um einsárs gamall enn hann lifir enn</Description>
            <Price>2Þ</Price>
            <ID>4</ID>
        </Item>
    </Stock>
</shop>


Dang ég þarf bara að búa til einn þráð yfir mig :-"


Annars er ég bara að brainstorma... Your input please :nerd_been_up_allnight