omregne kr til usd og euro?
Er det muligt at lave tal(dkr) der kommer fra en database og ind på siden med php om til henholdsvis euro og usd?Den skal vel bare omregne tallene hver gang den henter et nyt ind fra databasen.
Jeg bruger følgende script på siden:
<?php
include("db.php");
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$where = "";
if (isset($_GET['mainId']) && isset($_GET['itemType'])) {
$where = "WHERE mainId = " . $_GET['mainId'] . " AND itemType = '" . $_GET['itemType'] . "'";
} else if (isset($_GET['mainId'])) {
$where = "WHERE mainID = " . $_GET['mainId'];
}
if(isset($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
$prside = 20;
$basename = $_SERVER['PHP_SELF']."?mainId=".$_GET['mainId'];
$result = mysql_query("select * from items " . $where . " order by itemId asc LIMIT $start, $prside");
$q = mysql_query("select count(*) from items " . $where);
$num_rows = mysql_result($q, 0);
//connect
$query1 = mysql_query("SELECT * FROM overskrifter WHERE mainId = '".$_GET['mainId']."'")or die(mysql_error());
$overskrift = mysql_fetch_array($query1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript">
window.onload = function(){update();setInterval('update()',60000)}
function update(){
var d = new Date();
document.getElementById('minSpan').innerHTML = d.format("hh:uu | \\d. d. mmmm");
}
</script>
<script language="javascript" type="text/javascript" src="roenvingDate.js"></script>
<script language="javascript" type="text/javascript">
function popWin(file){
newWin=window.open("","ResizeBillede","width=300,height=200,status=no");
txt='<ht'+'ml><he'+'ad><ti'+'tle>Billedet i fuld størrelse<\57ti'+'tle><scri';
txt+='pt language="javascript" type="text/javascript">';
txt+='function resPic(){h=document.images[0].scrollHeight;';
txt+='w=document.images[0].scrollWidth;window.resizeTo(w+6,h+25);window.moveTo((screen.availWidth-w-6)/2,(screen.availHeight-h-25)/2)}<\57scri';
txt+='pt><\57he'+'ad><bo'+'dy style="overflow:hidden;';
txt+='border:0px;margin:0px"><i'+'mg src="'+file+'" style="top:0px;left:0px;border:0px;';
txt+='" onload="resPic();" onclick="self.close()" title="Tryk for at lukke vinduet"><\57bo'+'dy><\57ht'+'ml>';
newWin.document.write(txt);
newWin.document.close();
}
</script>
<title>Jernbanemaerker</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/styles.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style2 {color: #89744B}
-->
</style>
</head>
<body bgcolor="#D8C5A3">
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr align="right" valign="top">
<td width="900" height="143" class="top"><table width="555" height="138" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="bottom" class="style2"><p class="style2 style5"><?php include("menu.php"); ?></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top" class="body" bgcolor="#F2E3C8"><table width="106%" height="362" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="245" height="360" align="center" valign="top" class="left"><p> </p>
<table width="82%" border="0" cellpadding="0" cellspacing="0">
<tr align="left" valign="top" class="style2">
<td colspan="2"><h1>Mærker</h1>
<p>JERNBANEMÆRKER</p></td>
</tr>
<tr align="left" valign="top" class="style2">
<td width="7%"> </td>
<td width="93%"><p>
<a href="products.php?mainId=122">SAMLINGER</a><br>
<a href="products.php?mainId=112">ALS - BILERNE</a><br>
<a href="products.php?mainId=101">EBELTOFT - TRUSTRUP</a><br>
<a href="products.php?mainId=102">EBELTOFT - ÅRHUS</a> <br>
<a href="products.php?mainId=103">ÅRHUS - ODDER - HOU</a><br>
<a href="products.php?mainId=104">HORSENSBANEN</a><br>
<a href="products.php?mainId=105">HØNG - TØLLØSE</a><br>
<a href="products.php?mainId=106">KOLDING SYDBANER</a> <br>
<a href="products.php?mainId=107">LOLLANDSBANEN</a><br>
<a href="products.php?mainId=108">LYNGBY - NÆRUM </a><br>
<a href="products.php?mainId=109">MARIAGER - FAARUP - VIBORG</a> <br>
<a href="products.php?mainId=110">MARIBO - TORRIG</a><br>
<a href="products.php?mainId=111">NAKSKOV - KRAGENÆS</a><br>
<a href="products.php?mainId=113">NAKSKOV - RØDBY</a><br>
<a href="products.php?mainId=114">RANDERS - HADSUND</a><br>
<a href="products.php?mainId=115">RINGKØBING - ØRNHØJ - HOLSTEBRO</a><br>
<a href="products.php?mainId=116">R.G.G.J.</a><br>
<a href="products.php?mainId=117">SILKEBORG - KJELLERUP - RØDKÆRSBRO</a><br>
<a href="products.php?mainId=118">SVJ</a><br>
<a href="products.php?mainId=119">TROLDHEDE - KOLDING - VEJEN</a><br>
<a href="products.php?mainId=120">VEJLE – VANDEL - GRINDSTED </a><br>
<a href="products.php?mainId=121">ÅLBORG PRIVATBANER</a><br>
</p>
</td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2"> </td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2">JERNBANE ADRESSEKORT </td>
</tr>
<tr align="left" valign="top" class="style2">
<td> </td>
<td><a href="products.php?mainId=501">AMTSBANERNE PÅ ALS</a></td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2"> </td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2">PRØVETRYK / UDKAST </td>
</tr>
<tr align="left" valign="top" class="style2">
<td> </td>
<td><a href="products.php?mainId=601">LOLLANDSBANEN</a></td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2"> </td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2"><p>JULEMÆRKER</p></td>
</tr>
<tr align="left" valign="top" class="style2">
<td> </td>
<td><p>
<a href="products.php?mainId=203">SAMLINGER</a><br>
<a href="products.php?mainId=201">DK - OFFICIELLE JULEMÆRKER</a> <br>
<a href="products.php?mainId=202">LOKALE JULEMÆRKER</a> </p></td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2"> </td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2"><p>DAMPSKIBSMÆRKER</p></td>
</tr>
<tr align="left" valign="top" class="style2">
<td> </td>
<td><a href="products.php?mainId=301">SKJELSKØR</a><br>
<a href="products.php?mainId=302">NYKJØBING KYSTFART </a><br>
<a href="products.php?mainId=303">BAAGØ - FÆRGEFART A/S</a><br>
<a href="products.php?mainId=304">HORSENS</a></td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2"> </td>
</tr>
<tr align="left" valign="top" class="style2">
<td colspan="2">FÆRØERNE SKIBSMÆRKER </td>
</tr>
<tr align="left" valign="top" class="style2">
<td> </td>
<td><a href="products.php?mainId=401">SKIBSMÆRKER PÅ TALON</a> </td>
</tr>
</table>
<p> </p></td>
<td width="655" valign="top" class="middle"><p> </p> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="text">
<td> </td>
<td colspan="10" class="style2"><h1><?php echo $overskrift['overskrift1']?></h1></td>
</tr>
<tr class="text">
<td> </td>
<td colspan="10" class="style2"><?php echo $overskrift['overskrift2']?></td>
</tr>
<tr class="text">
<td colspan="11"><img src="gfx/prik.jpg" width="100%" height="1"></td>
</tr>
<tr class="text">
<td> </td>
<td valign="top">Billede</td>
<td valign="top"> </td>
<td valign="top"><p>Katalog nr/<br>
Årgang</p> </td>
<td width="40%" valign="top">Navn og beskrivelse </td>
<td width="1%" valign="top"> </td>
<td valign="top">Varetype</td>
<td valign="top"> </td>
<td align="right" valign="top">Pris</td>
<td valign="top"> </td>
<td valign="top">Læg i kurv</td>
</tr>
<tr class="text">
<td colspan="11"><img src="gfx/prik.jpg" width="100%" height="1"></td>
</tr>
<tr class="text">
<td colspan="11"> </td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr class="style2">
<td width="2%" height="43"> </td>
<td width="9%" border="0">
<?php
$p = (!empty($row["itemPhoto"]))? $row["itemPhoto"] : "notavail.jpg";
$t = (!empty($row["itemThumb"]))? $row["itemThumb"] : "notavail.jpg";
//echo "<A HREF='http://www.jernbanemaerker.dk/gallery/billeder/".$p."' target='_blank'> <img src='http://www.jernbanemaerker.dk/gallery/thumbs/".$t."'>";
echo "<a href=\"#\" onclick=\"popWin('http://www.jernbanemaerker.dk/gallery/billeder/".$p."');return false;\"><img src='http://www.jernbanemaerker.dk/gallery/thumbs/".$t."' border=0></a>";
//<a href="#" onclick="popWin('img/billede.jpg');return false;"><img src="img/billede.jpg" width="150" alt="Klik for fuld størrelse"></a>
?>
</td>
<td width="1%" border="0"> </td>
<td width="12%" align="left" valign="top" border="0"><font face="verdana" size="1" color="897448"><?php echo $row["katalognr"]; ?></font></td>
<td width="40%" valign="top"><p class="style2"><font face="verdana" size="1" color="897448"><?php echo $row["itemName"]; ?><br>
<?php echo $row["itemDesc"]; ?> </font></p> </td>
<td width="1%" valign="top"> </td>
<td width="10%" valign="top"><font face="verdana" size="1" color="897448"><?php echo str_replace("_", " ", $row['itemType']); ?></font></td>
<td width="4%" align="right" valign="top" class="style2">Kr. </td>
<td width="4%" align="right" valign="top" class="style2"><font face="verdana" size="1" color="897448"><?php echo " ".number_format($row["itemPrice"], 2, ",", ","); ?></font></td>
<td width="2%" valign="top" class="style2"> </td>
<td width="15%" valign="top"><a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1"><img src="gfx/cart.jpg" width="21" height="17" border="0"></a></td>
</tr>
<tr class="style2">
<td height="15" colspan="11"><img src="gfx/prik.jpg" width="100%" height="1"></td>
</tr>
<?php
}
?>
<tr class="style2">
<td colspan="11"><?
function tele2_pages ($prside, $num_rows, $basename, $s) {
$numPages = CEIL($num_rows / $prside);
if($numPages > 1) {
$now = ($_GET['s'] / $prside) + 1;
if($numPages <= 7) {
$start = 1;
$stop = $numPages;
} elseif(($now - 3) > 0 && ($now + 3) <= $numPages) {
$start = $now - 3;
$stop = $now + 3;
} elseif($now == $numPages || ($now + 2) == $numPages || ($now + 1) == $numPages) {
$start = $numPages - 6;
if( ($now - 6) < 1) {
while($start < 1) {
$start++;
}
}
$stop = $numPages;
} elseif($now == 1 || $now == 2 || $now == 3) {
$start = 1;
$stop = $start + 6;
if($stop > $numPages) {
while($stop > $numPages) {
$stop--;
}
}
}
$str = "
<table width='500' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td>
<div align=center>
<table align='center'>
<tr>
";
if($now > 1) $str .= "
<td width='20' align='center'><a class='style2' href='".$basename."&s=0'>«</a></td>
<td width='50' align='center'><a class='style2' href='".$basename."&s=".($now * $prside - 2 * $prside)."'>forrige</a>
";
if($start > 1) $str .= "
<td width='20' align='center'><a class='style2'>...</a></td>
";
for($i = $start; $i <= $stop; $i++) {
if($i == $now) {
$str .= "
<td width='20' align='center'><a class='tal_bar_now'>".$i."</td>
";
} else {
$str .= "
<td width='20' align='center'><a class='style2' href='".$basename."&s=".($i * $prside - $prside)."'>".$i."</a></td>
";
}
}
if($stop < $numPages) {
$str .= "
<td width='20' align='center'><a class='style2'>...</a></td>
";
}
if($now < $numPages) {
$str .= "
<td width='50' align='center'><a class='style2' href='".$basename."&s=".($now * $prside)."'>næste</a></td>
<td width='20' align='center'><a class='style2' href='".$basename."&s=".($numPages * $prside - $prside)."'>»</a></td>
";
}
$str .= "
</tr>
</table>
</div>
</td>
</tr>
</table>
";
}
return $str;
}
echo tele2_pages($prside, $num_rows, $basename, $start);
?></td>
</tr>
</table>
</td>
</tr>
<tr align="left">
<td height="2" colspan="2" valign="top" class="left"></td>
</tr>
</table> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" height="2" bgcolor="#D8C5A3"></td>
</tr>
<tr>
<td width="16%" align="right" valign="middle" id="dato" title="Dato" class="style2"><br>
<span id="minSpan"></span></td>
<td width="83%" align="right"><p class="style2"><br>
Design og programmering af Klaus Nissen, <a href="http://www.triodimenzionale.dk" target="_blank">www.Triodimenzionale.dk</a></p></td>
<td width="1%" align="right"> </td>
</tr>
<tr>
<td align="right" valign="middle" id="dato" title="Dato" class="style2"> </td>
<td align="right"> </td>
<td align="right"> </td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
<p> </p>
</body>
</html>
Håber nogen kan hjælpe mig =)
/SnigX