Counting PHP

Posts 1–8 of 8 · Page 1 of 1
Counting PHP
Heey guys, I just got eveloved in PHP but, something I don't understand and I googled it but could not find it.
How can I count, $toshiba["prijs"] + $acer["prijs"] + $HP["prijs"] ?

Virusscans
[1],[2]

This is my code:

Code:
<html>
	<head>
		<title>LAB 2, les 4</title>
	</head>
	<body>
		<header><b>HASH-arrays</b></header>
		<?php
			$toshiba["merk"] = " Toshiba Satellite ";
			$toshiba["model"] = " A100 ";
			$toshiba["OS"] = " Windows 8 ";	
			$toshiba["voorraad"] = 80;
			$toshiba["prijs"] = 999;
			$totaal = $toshiba["prijs"];
			$acer["merk"] = " Acer Aspire ";
			$acer["model"] = " 5732Z ";
			$acer["OS"] = " Linux ";	
			$acer["voorraad"] = 0;
			$acer["prijs"] = 888;
			$HP["merk"] = " HP ";
			$HP["model"] = " 200X ";
			$HP["OS"] = " Windows Vista ";	
			$HP["voorraad"] = 50;
			$HP["prijs"] = 777;
		echo("<table border='1'> " . "
			<caption>
			<strong>SML laptops</strong>
			</caption>
			<thead>
				<tr>
					<th>Merk</th><th>Model</th><th>Operating System</th><th>Voorraad</th><th>Prijs</th> 
				</tr>
			</thead>
			<tbody>
			<tr>
				<td>" . $toshiba["merk"] . "</td>" . "
				<td>" . $toshiba["model"]. "</td>" . "
				<td>" . $toshiba["OS"] . "</td>" . "
				<td>" . $toshiba["voorraad"] . "</td>" . "
				<td>" . $toshiba["prijs"] . "</td>" . "
			</tr>
			<tr>
				<td>" . $acer["merk"] . "</td>" . "
				<td>" . $acer["model"]. "</td>" . "
				<td>" . $acer["OS"] . "</td>" . "
				<td>" . $acer["voorraad"] . "</td>" . "
				<td>" . $acer["prijs"] . "</td>" . "
			</tr>
			<tr>
				<td>" . $HP["merk"] . "</td>" . "
				<td>" . $HP["model"]. "</td>" . "
				<td>" . $HP["OS"] . "</td>" . "
				<td>" . $HP["voorraad"] . "</td>" . "
				<td>" . $HP["prijs"] . "</td>" . "
			</tr>
				<tfoot>
					<tr> 
						<td colspan='4'>Totaal</td> <td> " . $totaal . "</td>
					</tr>
				</tfoot>
			</tbody>
		</table>");
		?>
	</body>
</html>
index_mpgh.net.rar638 B · 3 downloads Scanning…
<?php
$toshiba["merk"] = " Toshiba Satellite ";
$toshiba["model"] = " A100 ";
$toshiba["OS"] = " Windows 8 ";
$toshiba["voorraad"] = 80;
$toshiba["prijs"] = 999;
$acer["merk"] = " Acer Aspire ";
$acer["model"] = " 5732Z ";
$acer["OS"] = " Linux ";
$acer["voorraad"] = 0;
$acer["prijs"] = 888;
$HP["merk"] = " HP ";
$HP["model"] = " 200X ";
$HP["OS"] = " Windows Vista ";
$HP["voorraad"] = 50;
$HP["prijs"] = 777;
$totaal = $toshiba["prijs"] + $acer["prijs"] + $HP["prijs"];

maybe?

 
or


<?php
$toshiba["merk"] = " Toshiba Satellite ";
$toshiba["model"] = " A100 ";
$toshiba["OS"] = " Windows 8 ";
$toshiba["voorraad"] = 80;
$toshiba["prijs"] = 999;
$totaal = $toshiba["prijs"];
$acer["merk"] = " Acer Aspire ";
$acer["model"] = " 5732Z ";
$acer["OS"] = " Linux ";
$acer["voorraad"] = 0;
$acer["prijs"] = 888;
$totaal += $acer["prijs"];
$HP["merk"] = " HP ";
$HP["model"] = " 200X ";
$HP["OS"] = " Windows Vista ";
$HP["voorraad"] = 50;
$HP["prijs"] = 777;
$totaal += $HP["prijs"];
Yes, Thank you. That worked
Np, you posted the answer in your question : )

Quote Originally Posted by BGS. flameboy View Post
...
How can I count, $toshiba["prijs"] + $acer["prijs"] + $HP["prijs"] ?
...
$totaal = $toshiba["prijs"] + $acer["prijs"] + $HP["prijs"]

: p

w3schools is good for leaning the basics.
PHP Operators
any other questions tellme (y)
I laughed hard at this xD
Quote Originally Posted by rchayne View Post
I laughed hard at this xD
wauw thanks...
you can ask me if you need anything. :P this is toooo basic
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?