Re: Re: A beginner´s question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----- Original Message -----
From: Nathan Rixham <nrixham@xxxxxxxxx>
To: Eduardo <vareedu@xxxxxxxxx>
Cc: php-general@xxxxxxxxxxxxx
Date: Mon, 05 Jan 2009 03:00:19 +0000
Subject:  Re: A beginner´s question

> Eduardo wrote:
> > Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran.
> > I know that
> > 	$tastes=$_POST["tastes"]; 
> > moves the content of "tastes" from
> > 	<p><textarea rows="5" name="tastes" cols="28"></textarea></p>
> > to
> > 	$tastes
> > 
> > 
> > How do I move the content of $tastes to X of
> > 	echo "<textarea rows="5" cols="28" readonly name=X>\n";
> > ?
> > 
> > Thanks, 
> > Eduardo
> > 
> 
> echo "<textarea rows="5" cols="28" readonly name=" . $tastes . ">\n";
> 
> echo "this is how you echo a " . $variable . " in a string";



Small correction:

> echo "<textarea rows=\"5\" cols=\"28\" readonly name=" . $tastes . ">\n";
> 
> echo "this is how you echo a " . $variable . " in a string";

Need to escape the quotes if you use the same (single or double) type of quote for your HTML as you do for your PHP code.

Or...  (double quotes for PHP, single quotes for HTML)
> echo "<textarea rows='5' cols='28' readonly name=" . $tastes . ">\n";

Or... (single quotes for PHP, double quotes for HTML)
> echo '<textarea rows="5" cols="28" readonly name=' . $tastes . ">\n";

Or...  (my personal favorite.. double quotes for PHP and allowing $tastes to be translated to it's variable by including it within PHP's double quotes)
> echo "<textarea rows=\"5\" cols=\"28\" readonly name=$tastes>\n";


Or another option... (just echo the variable, not the whole line, via PHP)

<textarea rows="5" cols="28" readonly name=<?php echo $tastes; ?>>

(notice the >> on the end.. one is to close the PHP code, the other is to close the TEXTAREA tag)

-TG


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux