Old 03-18-2009   #1 (permalink)
Registered User
 
Space Cowboy's Avatar
 

Join Date: May 2005
Location: England (South)
Posts: 43

Variable data in text boxes

PHP Code:
// Display name field an error if needed
   
echo '<tr><td><label>Enter Student Number or Username<br /> 
    <input name="uid" type="text" id="uid" value="$name2" /></td></tr>'

I want the above text box value to be linked to the variable $name2 that can change.

Thanks Trev
__________________
Space Cowboy

Thanks for all the help here guys!
Space Cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-18-2009   #2 (permalink)
Janitor of Lunacy
 
Tamlin's Avatar
 

Join Date: May 2006
Location: Sitting in the Wishing Chair
Posts: 5,758
Blog Entries: 2
Images: 530

Battle Wins: 20 (rank: #1)
I'm not overly familiar with PHP, but I think you have to enclose variables in curly braces if you want to include them as part of a string.
Something like this:
PHP Code:
<?php

echo '<tr><td><label>Enter Student Number or Username<br />  
    <input name="uid" type="text" id="uid" value="{$name2}" /></td></tr>'
;

?>
__________________

"I might join your century, but only as a doubtful guest"
Tamlin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-18-2009   #3 (permalink)
Registered User
 
U'ziel's Avatar
 

Join Date: Sep 2005
Posts: 88
Images: 1

<input name="uid" type="text" id="uid" value="<?=$name2?>" />

The above in bold will work for PHP although I have been critized in the past that this is "messy" I've never seen Tamlins suggestion in a manual i'd be interested to know if that works for you!
U'ziel is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-18-2009   #4 (permalink)
Janitor of Lunacy
 
Tamlin's Avatar
 

Join Date: May 2006
Location: Sitting in the Wishing Chair
Posts: 5,758
Blog Entries: 2
Images: 530

Battle Wins: 20 (rank: #1)
I think I read it here: PHP: Strings - Manual
__________________

"I might join your century, but only as a doubtful guest"
Tamlin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-18-2009   #5 (permalink)
Registered User
 
U'ziel's Avatar
 

Join Date: Sep 2005
Posts: 88
Images: 1

oh sorry i read the originally post wrong i saw the table and thought he was wanting the variable in html don't know why I ignored the echo. I decided to test this here http://www.goolefitc.co.uk/test_brackets.php and it works great good tip Tamlin.

Alternative method below (think i may be switching to squiggly brackets tho!)

echo '<tr><td><label>Enter Student Number or Username<br />
<input name="uid" type="text" id="uid" value="'.$name2.'" /></td></tr>';
U'ziel is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-18-2009   #6 (permalink)
Registered User
 
Space Cowboy's Avatar
 

Join Date: May 2005
Location: England (South)
Posts: 43

Thanks Guys works perfectly.
__________________
Space Cowboy

Thanks for all the help here guys!
Space Cowboy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-21-2009   #7 (permalink)
Registered User
 

Join Date: Aug 2004
Posts: 143

PHP Code:
// Display name field an error if needed 
   
echo '<tr><td><label>Enter Student Number or Username<br />  
    <input name="uid" type="text" id="uid" value="'
.$name2.'" /></td></tr>'
PHP will read variables if you use double quotes. if you use single quotes you must escape then concatenate the string as above. If you want to avoid the concatenation you could use the code below. Note the difference in quote marks.

PHP Code:
// Display name field an error if needed 
   
echo "<tr><td><label>Enter Student Number or Username<br />  
    <input name='uid' type='text' id='uid' value='$name2' /></td></tr>"

Jolt is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-08-2009   #8 (permalink)
Registered User
 

Join Date: Apr 2009
Posts: 12

Quote:
Originally Posted by Tamlin View Post
I think I read it here: PHP: Strings - Manual
this site is very useful. I have also solved some problem from this site. thanks for sharing it.
harish is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Notification of Obsolete Data Purge - IMPORTANT! Man1c M0g Announcements 1 01-09-2009 07:59 PM
Camera data Kenneth Photography & Photo Manipulation 6 03-22-2007 12:27 AM
Constant in a variable in an evaled variable BlodoPKNZ HTML / PHP / ASP / JS 2 03-28-2005 10:01 AM
Text boxes that scroll... Runecaster HTML / PHP / ASP / JS 12 08-02-2004 08:43 PM
Indefinitely Variable Frank Jaeger HTML / PHP / ASP / JS 1 01-14-2004 06:03 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT