For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > September 2007 > need help with generating html source from the php









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author need help with generating html source from the php
shror

2007-09-26, 7:01 pm

Hi every body,

I need your help in a problem am facing,
I have two forms on my website which when submitted they goto single
page (confirmation.php) and the two forms are for English and Arabic
versions and what I want to do is to create a single confirmation page
which is responsible to send the forms values.
What I want to do is that when the arabic form is submitted the
confirmation echos arabic succesful note and when english an english
successful note is echoed which is easy to do but my problem is that
the <head> section of the confirmation contains a redirection meta tag
for the home page and I want the meta tag to be generated according to
the language interface, and I dont know how to generate HTML using the
php so please if anybody could help me this will be really
appreciated.
or even to direct me to a tutorial for this situation.

Thanks for help in advance

shror

macca

2007-09-26, 7:01 pm

Me thinks you need to read up a bit on php. Try http://w3schools.com/php/default.asp

$language = 'Arabic';

if ($language == 'Arabic'){

echo "<html><head><title>Some HTML and Arabic stuff</title></head>";

} elseif ($language == 'English'){

echo "<html><head><title>Some HTML and English stuff</title></head>";

} else {

echo "You must choose a Language";

}

Regards,

Paul

Jerry Stuckle

2007-09-26, 7:01 pm

shror wrote:
> Hi every body,
>
> I need your help in a problem am facing,
> I have two forms on my website which when submitted they goto single
> page (confirmation.php) and the two forms are for English and Arabic
> versions and what I want to do is to create a single confirmation page
> which is responsible to send the forms values.
> What I want to do is that when the arabic form is submitted the
> confirmation echos arabic succesful note and when english an english
> successful note is echoed which is easy to do but my problem is that
> the <head> section of the confirmation contains a redirection meta tag
> for the home page and I want the meta tag to be generated according to
> the language interface, and I dont know how to generate HTML using the
> php so please if anybody could help me this will be really
> appreciated.
> or even to direct me to a tutorial for this situation.
>
> Thanks for help in advance
>
> shror
>


<?php
echo "<b>This text is bold</b>\n";
?>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
shror

2007-09-27, 4:00 am

On Sep 26, 10:30 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> shror wrote:
>
>
>
>
> <?php
> echo "<b>This text is bold</b>\n";
> ?>
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================


I read about php on w3schools but the problem is that what I
understood is that the echo is used t echo something to the user to
read so that if I used

$language = 'Arabic';
if ($language == 'Arabic'){
echo "<html><head><title>Some HTML and Arabic stuff</title></head>";
} elseif ($language == 'English'){
echo "<html><head><title>Some HTML and English stuff</title></head>";
} else {
echo "You must choose a Language";
}

then I get on the page:
<html><head><title>Some HTML and English stuff</title></head>

anyway thanks for your help every body

shror

shror

2007-09-27, 4:00 am

On Sep 26, 10:21 pm, macca <ptmcna...@googlemail.com> wrote:
> Me thinks you need to read up a bit on php. Tryhttp://w3schools.com/php/default.asp
>
> $language = 'Arabic';
>
> if ($language == 'Arabic'){
>
> echo "<html><head><title>Some HTML and Arabic stuff</title></head>";
>
> } elseif ($language == 'English'){
>
> echo "<html><head><title>Some HTML and English stuff</title></head>";
>
> } else {
>
> echo "You must choose a Language";
>
> }
>
> Regards,
>
> Paul


I tried your example Paul and It worked great I really feel as dumb
but I have a small problem I don't know why it happened, I have
created a page using notepad and saved it .php and Unicode, but when I
tested it online it was not working so I Saved it as ANSI and tested
it once more and the code worked correctly why is this happening

Thanks for help in advance and the previous help too

shror

Sanders Kaufman

2007-09-27, 8:00 am

"shror" <shahirwm@gmail.com> wrote in message
news:1190829223.398719.48620@22g2000hsm.googlegroups.com...
> Hi every body,
>
> I need your help in a problem am facing,
> I have two forms on my website which when submitted they goto single
> page (confirmation.php) and the two forms are for English and Arabic
> versions and what I want to do is to create a single confirmation page
> which is responsible to send the forms values.


> What I want to do is that when the arabic form is submitted the
> confirmation echos arabic succesful note and when english an english
> successful note is echoed which is easy to do but my problem is that
> the <head> section of the confirmation contains a redirection meta tag
> for the home page and I want the meta tag to be generated according to
> the language interface, and I dont know how to generate HTML using the
> php so please if anybody could help me this will be really
> appreciated.
> or even to direct me to a tutorial for this situation.


That's difficult to impossible to say - without seeing the code.
I think it boils down to one comment - "I don't know how to generate HTML".

You could probably resolve your issue by finding the place in the code where
the META tag is generated and then to use a conditional (if-the-else) to
generate the appropriate line.


Jerry Stuckle

2007-09-27, 8:00 am

shror wrote:
> On Sep 26, 10:21 pm, macca <ptmcna...@googlemail.com> wrote:
>
> I tried your example Paul and It worked great I really feel as dumb
> but I have a small problem I don't know why it happened, I have
> created a page using notepad and saved it .php and Unicode, but when I
> tested it online it was not working so I Saved it as ANSI and tested
> it once more and the code worked correctly why is this happening
>
> Thanks for help in advance and the previous help too
>
> shror
>


Maybe because PHP is an ANSI language?

You don't need to save a file as unicode to send unicode to the browser.
And, in fact, if you do, you'll get other problems.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Shelly

2007-09-27, 7:02 pm


"Sanders Kaufman" <bucky@kaufman.net> wrote in message
news:82NKi.37169$RX.8150@newssvr11.news.prodigy.net...
> "shror" <shahirwm@gmail.com> wrote in message
> news:1190829223.398719.48620@22g2000hsm.googlegroups.com...
>
>
> That's difficult to impossible to say - without seeing the code.
> I think it boils down to one comment - "I don't know how to generate
> HTML".
>
> You could probably resolve your issue by finding the place in the code
> where the META tag is generated and then to use a conditional
> (if-the-else) to generate the appropriate line.


An interesting question occurred to me. Using the if statement outlined
previously in this thread, what happens with the echo when the desired
language reads from right to left and not left to right? Is it simply that
the entire string is captured in the quotes and so appears on the screen as
right to left? If that is the case, then what happens with word wrap?
Wouldn't it then break at the beginning of the sentence rather than in the
middle? (I have only worked on English sites).

Shelly


Sanders Kaufman

2007-09-27, 7:02 pm

"Shelly" <sheldonlg.news@asap-consult.com> wrote in message
news:13fnapid7bhrdb9@corp.supernews.com...
> "Sanders Kaufman" <bucky@kaufman.net> wrote in message


>
> An interesting question occurred to me. Using the if statement outlined
> previously in this thread, what happens with the echo when the desired
> language reads from right to left and not left to right?


I tend to buffer my echos until a block is fully composed.
I think there's a bunch of "ob****" stuff in PHP for that, but I just use a
variable.

Thus, the answer to your question is to do it like this:
code:
if($sLanguage == "english"){ $sMessage = "Good God, almighty!"; } else { $sMessage = "Allah akbar!"; } echo $sMessage;



> Is it simply that the entire string is captured in the quotes and so
> appears on the screen as right to left? If that is the case, then what
> happens with word wrap?


I don't understand the question.
You had me up until word-wrap.
When you echo a string, as shown - it spits the result out to std_out as
composed.
There's no word-wrap unless the client is doing something like that.
Does that help answer the question?


> Wouldn't it then break at the beginning of the sentence rather than in the
> middle? (I have only worked on English sites).


Huh? Not in any context I can think of.



macca

2007-09-27, 7:02 pm

Never worked with anything but English but I do know that text
direction can be controlled with CSS e.g.

p {
direction:rtl;

text-align:right
}

Shelly

2007-09-27, 7:02 pm


"Sanders Kaufman" <bucky@kaufman.net> wrote in message
news:o1PKi.9168$JD.5519@newssvr21.news.prodigy.net...
> "Shelly" <sheldonlg.news@asap-consult.com> wrote in message
> news:13fnapid7bhrdb9@corp.supernews.com...
>
> I don't understand the question.
> You had me up until word-wrap.
> When you echo a string, as shown - it spits the result out to std_out as
> composed.
> There's no word-wrap unless the client is doing something like that.
> Does that help answer the question?


As one example, if you have a table of fixed column width and allow
multi-line (a not uncommon situaton), then the text will wrap. What happens
if that text is supposed to be right to left? Treating it all as a one left
to right string will cause it to wrap incorrectly. Does that help you
understand the question?

>
>
>
> Huh? Not in any context I can think of.


"ggg fff eee ddd ccc bbb aaa" will wrap as, for example,

"ggg fff eee ddd"
"ccc bbb aaa"

because it assumes left to right. In a right to left language, aaa is the
the first word, bbb the second, etc. We would want it to wrap as:

"ddd ccc bbb aaa"
" ggg fff eee"

That is what I meant. How does one make that kind of thing happen. A
simple echo will wrap incorrectly.

Shelly

>
>
>



Shelly

2007-09-27, 7:02 pm


"macca" <ptmcnally@googlemail.com> wrote in message
news:1190903345.329646.114740@w3g2000hsg.googlegroups.com...
> Never worked with anything but English but I do know that text
> direction can be controlled with CSS e.g.
>
> p {
> direction:rtl;
>
> text-align:right
> }
>


Now THAT answers my question!

Shelly


Sanders Kaufman

2007-09-28, 8:01 am

"Shelly" <sheldonlg.news@asap-consult.com> wrote in message
news:13fnjqlt7862n23@corp.supernews.com...
> "Sanders Kaufman" <bucky@kaufman.net> wrote in message


>
> As one example, if you have a table of fixed column width and allow
> multi-line (a not uncommon situaton), then the text will wrap. What
> happens if that text is supposed to be right to left? Treating it all as
> a one left to right string will cause it to wrap incorrectly. Does that
> help you understand the question?


Yeah, I think so.
But for that - you're best answer can be found in the PHP docs at PHP.net -
if you're using PHP's wordwrap thingy.
I don't use it much.


> because it assumes left to right. In a right to left language, aaa is the
> the first word, bbb the second, etc. We would want it to wrap as:
>
> "ddd ccc bbb aaa"
> " ggg fff eee"
>
> That is what I meant. How does one make that kind of thing happen. A
> simple echo will wrap incorrectly.


You'll probably have to create your own function for that.
I don't think PHP is *that* internationalized yet.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com