473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Variables not printing in HTML

In the middle of an HTML document, I am adding some php code to display
some text only if a variable is set. Here is my code:

<?

$people = $_POST['people'];
$people_fee= $people * 10;

$people_text='<tr bgcolor="#ffffff">
<td valign="top"width="25%"><font size="2" color="black"
face="arial">Extra people</td>
<td valign="top" width="60%" align="left"><font size="2"
color="black" face="arial">Analysis of, or compatibility with, <?
print($people); ?> other person(s) (first person included without
charge)
</td>
<td valign="top" width="15%" align="left"><font size="2" color="black"
face="arial"><?print( $people_fee)?><br>
</td>
</tr>';

if ($people) {
print ($people_text);
}
?>
The above partially works. If $people has anything in it, the HTML
displays the text saying "Extra people," etc. But the value of $people
and $people_fee do not print out. Why is this?

Thank you.

Jul 17 '05 #1
2 1759
On 21 Jan 2005 17:01:47 -0800, "Robert" <ro********@starcenter.com> wrote:
In the middle of an HTML document, I am adding some php code to display
some text only if a variable is set. Here is my code:

<?
$people = $_POST['people'];
$people_fee= $people * 10;

$people_text='<tr bgcolor="#ffffff">
<td valign="top"width="25%"><font size="2" color="black"
face="arial">Extra people</td>
<td valign="top" width="60%" align="left"><font size="2"
color="black" face="arial">Analysis of, or compatibility with, <?
print($people); ?> other person(s) (first person included without
charge)
</td>
<td valign="top" width="15%" align="left"><font size="2" color="black"
face="arial"><?print( $people_fee)?><br>
You're trying to embed PHP inside a PHP string - this won't then execute as
PHP, it'll just come out as <?print ... etc., which looks like an unknown tag,
which browsers will then just ignore.

If you want variable's value in the string, then either:

(a) Use double quotes, and lose the '<?print(' and '?>'
(b) Concatenate it in, i.e.

$people_text = '...arial">' . $people_fee . '<br>...';
</td>
</tr>';

if ($people) {
print ($people_text);
}
?>

The above partially works. If $people has anything in it, the HTML
displays the text saying "Extra people," etc. But the value of $people
and $people_fee do not print out. Why is this?


--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
.oO(Robert)
In the middle of an HTML document, I am adding some php code to display
some text only if a variable is set. Here is my code:

<?
[...]

The above partially works. If $people has anything in it, the HTML
displays the text saying "Extra people," etc. But the value of $people
and $people_fee do not print out. Why is this?


Have a look at the generated HTML code, it should give you an idea
what's wrong.

Micha
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: divya | last post by:
This is the problem I am having: I have an index page where I obtain input from the user (for example their date of birth). This information is passed to Page2. Page2 has frames. Outside of the...
5
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of...
7
by: Dennis C. Drumm | last post by:
I was wondering if someone could suggest were/how I could get started with setting up printing of a collection of text that includes tables from a grid and other supporting information about the...
2
by: Jurjen de Groot | last post by:
I'm about to start a new ASP.NET application, this application will generate several types of documents (PDF HTML XML-DOC) wich have to be printed at the client-side... (probably on different...
1
by: sconeek | last post by:
hi all, I am working on a virtual keyboard. the page is a combination of html and javascript. the html page is made up of a lot of frames. now i am unable to implement the actual keyboard...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
4
by: Lucas Ponzo | last post by:
Hi All, I have an ASP.NET 2.0 app. The users access the pages, uniquely via pocket pc ... I need to print a page. But I need that the page print on a printer installed on the web server...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
0
by: nikhilgargi | last post by:
Requirement: I need to provide printing capability in a C# desktop application that I am developing The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom...
1
by: xamalek | last post by:
I was thinking that when you override a struct variable when you are subclassing the struct, then the variable in the new struct would stomp on the old one ... (i.e.) the parent variable (i) and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.