HardwareLogic

Go Back   HardwareLogic > Specific Hardware > Internet/Networking
Home Forums Rules All AlbumsBlogs Subscriptions Register Mark Forums Read

Internet/Networking Everything concerning your internet connection or network, as well as browsers.

Closed Thread
 
LinkBack Thread Tools
Old November 13th, 2006   #11
Banned
 
yurimxpxman's Avatar
 
Join Date: Jun 2006
Location: /home/yurimxpxman
Posts: 1,695
Default

My bad. Zambini, I incorrectly told you that man's username was PC__MAX. His username is actually PC__GUY. I'm inviting him to the HL forums right now :)
yurimxpxman is offline  
Old November 13th, 2006   #12
Level 2 College Student
 
Zambini's Avatar
 
Join Date: Oct 2006
Location: St. Mere du SantaCruz
Posts: 2,103
Blog Entries: 1
Default

heheh. I see =) That's why his name wasnt there either.

ps: I should make my penguin a tiny little hat just like urs ^^





Zambini is offline  
Old November 13th, 2006   #13
Banned
 
yurimxpxman's Avatar
 
Join Date: Jun 2006
Location: /home/yurimxpxman
Posts: 1,695
Default

LOL! That'd be friggen' hilarious! Find a little Santa hat this Christmas for your little penguin doll. Post some pics for us
yurimxpxman is offline  
Old November 13th, 2006   #14
Level 2 College Student
 
Zambini's Avatar
 
Join Date: Oct 2006
Location: St. Mere du SantaCruz
Posts: 2,103
Blog Entries: 1
Default

Guess who got a new hat!





Zambini is offline  
Old November 14th, 2006   #15
Banned
 
yurimxpxman's Avatar
 
Join Date: Jun 2006
Location: /home/yurimxpxman
Posts: 1,695
Default

LOL! I love it. It looks great! :P
yurimxpxman is offline  
Old November 15th, 2006   #16
 
pc_guy's Avatar
 
Join Date: Nov 2006
Location: Inside an igloo, Canada
Posts: 313
Default

Hey yurimxpxman, Zambini - I'm now officially registered on the forum!

I will get down to business right away.

Zambini,
I have some good news and some bad news about your problem:

The bad news is that even if there was some super easy way of loading/calculating, XML, database table(I like to use a db). You still need to do Price * quantity = answer. There isn't a simpler way of doing it, A+B=C, A*B=C, there is no way around it.

The good news is that you only do need simple calculation like A*B=C, so it will not be hard to do it. There is two ways I'm thinking of doing it, I'll start with the easier one first.

I'll try to put together a sample.

Stay tuned!



|| AMD Athlon64 3800+ Venice | Asus A8N5X s939 | OCZ Premier PC3200 Du-Ch 1GB | Sapphire X1600Pro 512MB PCI-e | 1xWD 80Gb & 1xWD 250Gb Sata(s) | Antec SLK3800B Case | Enermax NoiseTaker 485W ||
pc_guy is offline  
Old November 15th, 2006   #17
Level 2 College Student
 
Zambini's Avatar
 
Join Date: Oct 2006
Location: St. Mere du SantaCruz
Posts: 2,103
Blog Entries: 1
Default

Don't work too hard, i don't know whether I'm going to be buying another timecard for eve yet...

however knowing XML will definitely help..... so I still wanna know =)

thx ^^





Zambini is offline  
Old November 16th, 2006   #18
 
pc_guy's Avatar
 
Join Date: Nov 2006
Location: Inside an igloo, Canada
Posts: 313
Default

Had some extra time to work on this, was waiting for someone to come over but they never did.

It's a simple example using your table from the excel file.
Most of it is PHP/HTML, with only a few lines to import the XML. Even if you don't use it, it's still a good example for future projects.

Below is the code,

XML file - minerals.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<allminerals>
<minerals>
    <mineral>
        <mname>Arkonor</mname>
        <volume>16</volume>
        <cargo>4500</cargo>
    </mineral>
    <mineral>
        <mname>Triclinic Bistot</mname>
        <volume>16</volume>
        <cargo>675</cargo>
    </mineral>
    <mineral>
        <mname>Crokite</mname>
        <volume>16</volume>
        <cargo>675</cargo>
    </mineral>
    <mineral>
        <mname>Gneiss</mname>
        <volume>5</volume>
        <cargo>675</cargo>
    </mineral>
    <mineral>
        <mname>Hedbergite</mname>
        <volume>3</volume>
        <cargo>675</cargo>
    </mineral>
    <mineral>
        <mname>Hemorphite</mname>
        <volume>3</volume>
        <cargo>675</cargo>
    </mineral>    
</minerals>
</allminerals>
The PHP file - calc1.php:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minerals</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
input {
 background-color:#ffffff; 
 border: 1px solid #CCC4BD;
 color:#000000; 
 padding:3px 3px 3px 3px;
 }

 .button1 {background-color:#FF6600;
}
TD {
 border: 1px solid #CBCED8;
}
-->
</style>
</head>
<body>
<form action="calc1.php" method="post" name="calculate">
<table cellpadding="2" cellspacing="0" class="newborder">
  <tr bgcolor="#CCCCCC">
    <td width="183"><div align="center"><strong>Ore Name </strong></div></td>
    <td width="148"><div align="center"><strong>Amount </strong></div></td>
    <td width="148"><div align="center"><strong>Price Each </strong></div></td>
    <td width="148"><div align="center"><strong>Gross Return </strong></div></td>
    <td width="148"><div align="center"><strong>Net Profit </strong></div></td>
    <td width="148"><div align="center"><strong>Volume </strong></div></td>
    <td width="148"><div align="center"><strong>Your Cargo </strong></div></td>
    <td width="148"><div align="center"><strong>Profit Per Load </strong></div></td>
    <td width="152"><div align="center"><strong>Possible Carry </strong></div></td>
  </tr>

<?php
/////////////
//Load the XML file into arrays
//////////////
$namespos = 0;
if (file_exists('articles.xml'))
  {
  $xml = simplexml_load_file('minerals.xml');
    foreach($xml->minerals as $minerals){
        foreach($minerals->mineral as $mineral){
            $names[$namespos] = $mineral->mname;
            $volume[$namespos] = $mineral->volume;
            $cargo[$namespos] = $mineral->cargo;
            $namespos++;
        }
    }
}else
  {
  exit('Error.');
  }
//That's it for XML
//The rest is HTML/PHP using our loaded info



/////////////////////////
//create the table rows with the mineral names, amounts, price, etc..
/////////////////////////
$num = 0;
$i = 0;
$numofrows = 0;

$totalamount = 0;
$totalprice = 0;
$totalgross = 0;
$totalnet = 0;
$totalperload = 0;

//how much mineral names in array
$numofrows = sizeof($names);

//set price,amount arrays from POST, they will be zero if pge loads for first time
//Every time user clicks Calculate! button, it will relead the page
while($i<=$numofrows)
  {
  $amount[$i] =$_POST["amount".$i];
  $price[$i] =$_POST["price".$i];
  $i++;
  }

//loop through all the names and generate HTML table rows
foreach ($names as $thename)
{
    
$netprofit = ($amount[$num] * $price[$num])*0.99;

//While we loop, calculate the totals for latter output at the end of the table
$totalamount = $totalamount+$amount[$num];
$totalprice = $totalprice+$price[$num];
$totalgross = $totalgross+($amount[$num] * $price[$num]);
$totalnet = $totalnet+$netprofit;
$totalperload = $totalperload+(($cargo[$num]/$volume[$num])*$price[$num]);

print '<tr>';
    print '<td bgcolor="#999999" class="xl33"><strong>'.$thename.'</strong></td>'."\r";
    print '<td align="right"><input name="amount'.$num.'" value="'.$amount[$num].'" type="text" size="14" maxlength="14"></td>'."\r";
    print '<td align="right"><input name="price'.$num.'" value="'.$price[$num].'" type="text" size="14" maxlength="14"></td>'."\r";
    print '<td calign="right">'.$amount[$num] * $price[$num].'</td>'."\r";
    print '<td align="right">'.$netprofit.'</td>'."\r";
    print '<td align="right">'.$volume[$num].'</td>'."\r";
    print '<td align="right">'.$cargo[$num].'</td>'."\r";
    print '<td align="right">'.($cargo[$num]/$volume[$num])*$price[$num].'</td>'."\r";
    print '<td align="right">'.$cargo[$num]/$volume[$num].'</td>'."\r";
  print '</tr>';
print '<tr>';
print "\r\r";

$num++;
}

?>

 <tr>
    <td bgcolor="#999999">&nbsp; </td>
    <td bgcolor="#999999"><div align="center">Total </div></td>
    <td bgcolor="#999999"><div align="center">Total </div></td>
    <td bgcolor="#999999"><div align="center">Total </div></td>
    <td bgcolor="#999999"><div align="center">Total </div></td>
    <td bgcolor="#999999"> <div align="center"></div></td>
    <td bgcolor="#999999"> <div align="center"></div></td>
    <td bgcolor="#999999"><div align="center">Total </div></td>
    <td bgcolor="#999999"><div align="center"></div></td>
  </tr>
  <tr>
    <td bgcolor="#999999"></td>
    <td align="center"><? print $totalamount; ?></td>
    <td align="center"><? print $totalprice; ?></td>
    <td align="center"><? print $totalgross; ?></td>
    <td align="center"><? print $totalnet; ?>
      </td>
    <td></td>
    <td></td>
    <td align="center"><? print $totalperload; ?></td>
    <td></td>
  </tr>
</table>
<br>
<br>
<input name="calc" type="submit" class="button1" value="Calculate!">
</form>
</body>
</html>
Right now, it uses the excel file formulas and totals the results. You will need PHP5 support on your server to run the simplexml_load_file part.

This should get you started.



|| AMD Athlon64 3800+ Venice | Asus A8N5X s939 | OCZ Premier PC3200 Du-Ch 1GB | Sapphire X1600Pro 512MB PCI-e | 1xWD 80Gb & 1xWD 250Gb Sata(s) | Antec SLK3800B Case | Enermax NoiseTaker 485W ||
pc_guy is offline  
Old November 16th, 2006   #19
Banned
 
yurimxpxman's Avatar
 
Join Date: Jun 2006
Location: /home/yurimxpxman
Posts: 1,695
Default

pc_guy: Is that script written to support Firefox or is that another IE-only one?
yurimxpxman is offline  
Old November 16th, 2006   #20
 
pc_guy's Avatar
 
Join Date: Nov 2006
Location: Inside an igloo, Canada
Posts: 313
Default

It's all server-side PHP code, so it should run on all browsers.

To tell you the truth, I haven't even tried it in IE yet, been testing it in FF.



|| AMD Athlon64 3800+ Venice | Asus A8N5X s939 | OCZ Premier PC3200 Du-Ch 1GB | Sapphire X1600Pro 512MB PCI-e | 1xWD 80Gb & 1xWD 250Gb Sata(s) | Antec SLK3800B Case | Enermax NoiseTaker 485W ||
pc_guy is offline  
Closed Thread

  HardwareLogic > Specific Hardware > Internet/Networking

Tags
php, script


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DHCP profile, locating and identi file or script? Tech Geek Deluxe Troubleshooting 3 November 13th, 2007 15:21
differential backups script for Unix yurimxpxman Software & OSs 0 May 16th, 2007 21:37
Gaim currently listening script for Amarok yurimxpxman Software & OSs 8 February 26th, 2007 16:31


All times are GMT -8. The time now is 09:35.


Powered by vBulletin® Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
© HardwareLogic 2005 - 2008. All Rights Reserved


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52