[php] Standard crafting page

Development of graphics and web assets.

[php] Standard crafting page

Postby Ramy » Thu Mar 15, 2012 12:51 pm

I thought I'd share this, It doesn't include the query and db class you'd have to write one your own depending on the version of php you're using. It uses the view that's posted in the server section.

the following functions are calls to templates:
mheader();
buildncraftrow();
mfooter();

You can write your own with whatever layout you want in html and put the invoked vars any place you like with shorttag php thing or echo.

Code: Select all
<?php

include 'header.php'; //this would be where you include your db and query class

    $query_getdata = new query($SQL, "SELECT * FROM [dbo].[normalcraft]");
 
//    headers for template
$mess = 'Standard Crafting List';
$title = 'Standard Crafting List';
$subtitle = 'Standard Crafting List';
$descript = 'Detail and sorting order options coming soon..';

mheader($title,$subtitle,$descript);
getdata($query_getdata);

function getdata($q){
      if($q->fetch()) {


          // Item
          $iname = $q->field('strName');
          $ipic = $q->field('sPicNum1');
         $slottype = $q->field('sType01');
         $crafttype = $q->field('sExpType');
         $needexp = $q->field('sNeedExp');
         $maxab = $q->field('sMaxAb');
         $metal = $q->field('sMetal');
         $wood = $q->field('sWood');
         $leather = $q->field('sLeather');
         $bone = $q->field('sBone');
         $cloth = $q->field('sCloth');
         $plant = $q->field('sPlant');
         $meat = $q->field('sMeat');
         $powder = $q->field('sPowder');
         $spice = $q->field('sSpice');
         $gem = $q->field('sGems');
         
      //set types and slots
   switch ($slottype) {
   case 0:
        $slottype = "Anywhere";
        break;
   case 1:
        $slottype = "Forge[One handed sword]";
        break;
   case 2:
        $slottype = "Forge[Two handed sword]";
        break;
   case 4:
        $slottype = "Forge Axe";
        break;
   case 5:
        $slottype = "Forge Bow";
        break;
   case 6:
        $slottype = "Forge Spear";
        break;
   case 7:
        $slottype = "Forge Knuckle";
        break;
   case 8:
        $slottype = "Forge Staff";
        break;
   case 9:
        $slottype = "Forge Armour[Top]";
        break;
   case 3:
        $slottype = "??";
        break;
   case 10:
        $slottype = "Forge Armour[Pads]";
        break;
   case 11:
        $slottype = "Forge Armour[Boots]";
        break;
   case 12:
        $slottype = "Loom[Robe]";
        break;
   case 13:
        $slottype = "Loom Clothing[Top]";
        break;
   case 14:
        $slottype = "Loom Clothing[Pads]";
        break;
   case 15:
        $slottype = "Loom[Shoes]";
        break;
   case 16:
        $slottype = "Anvil[Ring]";
        break;
   case 17:
        $slottype = "Anvil[Bracelet]";
        break;
   case 18:
        $slottype = "Anvil[Necklace]";
        break;
   case 19:
        $slottype = "Anvil[Earring]";
        break;
   case 20:
        $slottype = "Reagent Table";
        break;
   case 21:
        $slottype = "Oven[Cook]";
        break;
   case 22:
        $slottype = "Forge Armour[Helm]";
        break;
   case 23:
        $slottype = "Forge Armour[Shield]";
        break;
}

  switch ($crafttype) {
      case 0:
        $crafttype = "Weapon";
        break;
      
      case 1:
        $crafttype = "Armor";
        break;
      
      case 2:
        $crafttype = "Accessory";
        break;
      
      case 3:
        $crafttype = "Potion";
        break;
      
      case 4:
        $crafttype = "Cooking";
        break;
      
      case 10:
        $crafttype = "Gem?";
        break;
      
}

// set needed exp and skill

$needexp = $crafttype . "(" . $needexp . ")";

               
//buildncraftrow is the the template that is called for every item in the table
      buildncraftrow($iname,$ipic,$slottype,$needexp,$maxab,$metal,$wood,$leather,$bone,$cloth,$plant,$meat,$powder,$spice,$gem);
     // recursive call
     getdata($q);

   }
//else do nothing

}



// footers template
mfooter($mess,$intuser);


?>



User avatar
Ramy
SD Four Star
SD Four Star
 
Posts: 213
Joined: Fri Feb 29, 2008 1:20 pm

Re: [php] Standard crafting page

Postby arcanine » Thu Mar 15, 2012 12:53 pm

:o have you got an example of the page in action?
User avatar
arcanine
SD Pro 5 Star
SD Pro 5 Star
 
Posts: 1056
Joined: Mon Apr 21, 2008 2:53 pm

Re: [php] Standard crafting page

Postby Ramy » Thu Mar 15, 2012 1:18 pm

User avatar
Ramy
SD Four Star
SD Four Star
 
Posts: 213
Joined: Fri Feb 29, 2008 1:20 pm

Re: [php] Standard crafting page

Postby soulsomaa » Thu Mar 15, 2012 3:32 pm

just having a look that looks good but you could also sort them so there under diferent categories for example have a pull down bar so you can choose be tween armours and weps

Code: Select all
Armours -> Helm
                 Tops
                 Pads
                 Boots

Weapons -> Axes
                  Bows
                  Spears
                  Swords
                  Staffs


Same for items and upgrades
Image
soulsomaa
SD Three Star
SD Three Star
 
Posts: 101
Joined: Sat Mar 10, 2012 7:07 pm


Return to Graphics and Website development

Who is online

Users browsing this forum: No registered users and 3 guests

cron