tags:

views:

154

answers:

1

Hi,

I've gota working form that when you click "submit" it takes you to a results page - all fine.

However, is it possible to add divs etc to make the page look a bit nicer? If so, how? At the moment when i add divs in it just ignores them!

Thanks, Steph

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
<link rel="stylesheet" href="styleResults.css" type="text/css" media="all" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<TITLE>Ideo Accounting - Results</TITLE>
</head>
<body>
<H2>Results</H2>

<?
$customers = $_POST['customers'];
$suppliers = $_POST['suppliers'];
$bank = $_POST['bank'];
$creditcard = $_POST['creditcard'];

$totalqty = 0;
$totalamount = 0.00;

define("PRICE", 0.75);

$totalqty = $customers + $suppliers + $bank + $creditcard;
$totalamount = number_format($totalqty*PRICE, 2);

echo "<BR>\n";
echo "Total transactions: $totalqty<br>\n";
echo "Estimated monthly fee: &pound;$totalamount<BR>\n";

?>
</body>
</html>
+1  A: 

You can put any HTML styling elements in between the " double quotes after the echo statements, they will definitely not be ignored.

Look into your browser's "view source" page to see whether they get output or not. My guess is the divs you output have no CSS styling at all, so you won't see anything.

Code improvement suggestion:

It might be easier to work with the HTML if you change its structure a bit. Remove the three echo lines, and after the ?> add

<BR>
Total transactions: <?php echo $totalqty;?><br>
Estimated monthly fee: &pound;<?php echo $totalamount;?><BR>

the PHP output is then part of your HTML code, and you can place divs and other elements as you please without having to take care not to break the PHP string. You can even move the <?php=$...?> snippets around, you just have to be careful that they stay intact.

Pekka
I've tried the code improvement suggestion you said but it says:syntax error, unexpected '=' in line 35 (which is the Total transactions: <?php=$totalqty;?><br> line)....
Steph
I think it's more like this: <?php echo $totalqty; ?><br>
Phill Pafford
@Phill @Steph cheers, good point. I forgot that the `=` notation works with short open tags only. Changed the example.
Pekka
it's working beautifully now! Thanks guys =)
Steph
<?php= is apparently scheduled for inclusion in PHP 6
Marc B