![]() |
| |||||||
| Home | Forums | Rules | All Albums | Blogs | Subscriptions | Register | Mark Forums Read |
| Internet/Networking Everything concerning your internet connection or network, as well as browsers. |
![]() |
| | LinkBack | Thread Tools |
| | #11 |
| Banned Join Date: Jun 2006 Location: /home/yurimxpxman
Posts: 1,695
| 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 :) |
| |
| | #13 |
| Banned Join Date: Jun 2006 Location: /home/yurimxpxman
Posts: 1,695
| LOL! That'd be friggen' hilarious! Find a little Santa hat this Christmas for your little penguin doll. Post some pics for us ![]() |
| |
| | #15 |
| Banned Join Date: Jun 2006 Location: /home/yurimxpxman
Posts: 1,695
| LOL! I love it. It looks great! :P |
| |
| | #16 |
| Join Date: Nov 2006 Location: Inside an igloo, Canada
Posts: 313
| 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 || |
| |
| | #17 |
| Level 2 College Student | 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 ^^ |
| |
| | #18 |
| Join Date: Nov 2006 Location: Inside an igloo, Canada
Posts: 313
| 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>
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"> </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>
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 || |
| |
| | #19 |
| Banned Join Date: Jun 2006 Location: /home/yurimxpxman
Posts: 1,695
| pc_guy: Is that script written to support Firefox or is that another IE-only one? |
| |
| | #20 |
| Join Date: Nov 2006 Location: Inside an igloo, Canada
Posts: 313
| 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 || |
| |
![]() |
|
| Tags |
| php, script |
| Thread Tools | |
|
|
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 |