jacaranda Posted April 11, 2007 Share Posted April 11, 2007 Hi, hope someone could shed a light on this... Im having trouble displaying the correct value of a variable.. which is take from a database... I have this for the query part... $query = "SELECT * FROM auth_users WHERE user_id LIKE '{$_SESSION[userId]}' ORDER BY work_week DESC"; $result = mysql_query($query) or die('Query failed. ' .mysql_error()); $row = mysql_fetch_array($result); when I do an echo, say: echo "<p>$row[activity_1]"; output is correct... say 'this is the content' .. (w/o quotes) But when i put the $row[activity_1] inside a textbox 'value=' part.. the only thing that's displayed is 'this'... after the space, nothing.. <td width="70%"> <input disabled="yes" type="text" name="LWActivity1" size="20" <?php echo "value= $row[activity_1]" ?>> <td> Itried playing around with the quotes and things, but nothign... I hope this is enough info, Thanks for your help... Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 11, 2007 Share Posted April 11, 2007 $row[activity_1] is not right use $row['activity_1']. and use this <input disabled="yes" type="text" name="LWActivity1" size="20" <?php echo " value= $row['activity_1']" ?>> Quote Link to comment Share on other sites More sharing options...
craygo Posted April 11, 2007 Share Posted April 11, 2007 Should be this <input disabled="yes" type="text" name="LWActivity1" size="20" value="<?php echo $row['activity_1']; ?>"> Ray Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 11, 2007 Share Posted April 11, 2007 Should be this <input disabled="yes" type="text" name="LWActivity1" size="20" value="<?php echo $row['activity_1']; ?>"> Ray Ya we natuarally do this. but he wanna echo 'value' also with php echo Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 11, 2007 Share Posted April 11, 2007 Then the code should be: <input disabled="yes" type="text" name="LWActivity1" size="20" <?php echo 'value="' . $row['activity_1'] . '"'; ?>> Ken Quote Link to comment Share on other sites More sharing options...
jacaranda Posted April 11, 2007 Author Share Posted April 11, 2007 tried this once, but the value didn't change.. still the one word output... Should be this <input disabled="yes" type="text" name="LWActivity1" size="20" value="<?php echo $row['activity_1']; ?>"> Ray Ya we natuarally do this. but he wanna echo 'value' also with php echo Quote Link to comment Share on other sites More sharing options...
jacaranda Posted April 11, 2007 Author Share Posted April 11, 2007 it caused a '`T_STRING' or `T_VARIABLE' or `T_NUM_STRING' ' parse error.. also tried this.. echo "<p>$row[activity_1]"; displays the contect perfectly, but not in the html form... $row[activity_1] is not right use $row['activity_1']. and use this <input disabled="yes" type="text" name="LWActivity1" size="20" <?php echo " value= $row['activity_1']" ?>> Quote Link to comment Share on other sites More sharing options...
jacaranda Posted April 11, 2007 Author Share Posted April 11, 2007 It WORKED! Geezzz.. how is that?! (have to break that one apart....) Thanks plenty! Then the code should be: <input disabled="yes" type="text" name="LWActivity1" size="20" <?php echo 'value="' . $row['activity_1'] . '"'; ?>> Ken Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 11, 2007 Share Posted April 11, 2007 My code should work. The other way of writing it would be: <?php echo '<input disabled="yes" type="text" name="LWActivity1" size="20" value="' . $row['activity_1'] . '">'; ?> or <?php echo '<input disabled="yes" type="text" name="LWActivity1" size="20" value="{$row['activity_1']}">'; ?> Ken (edit: was posting this as you posted your reply) Quote Link to comment Share on other sites More sharing options...
craygo Posted April 11, 2007 Share Posted April 11, 2007 well if activity_1 has spaces in it you will get an error <input disabled="yes" type="text" name="LWActivity1" size="20" <?php echo "value='".$row['activity_1']."'" ?>> Quote Link to comment Share on other sites More sharing options...
jacaranda Posted April 11, 2007 Author Share Posted April 11, 2007 Well, it did work sir. Thanks very much! My code should work. The other way of writing it would be: <?php echo '<input disabled="yes" type="text" name="LWActivity1" size="20" value="' . $row['activity_1'] . '">'; ?> or <?php echo '<input disabled="yes" type="text" name="LWActivity1" size="20" value="{$row['activity_1']}">'; ?> Ken (edit: was posting this as you posted your reply) Quote Link to comment Share on other sites More sharing options...
jacaranda Posted April 11, 2007 Author Share Posted April 11, 2007 yeah, ken made it perfectly sure that i notice the space in between.. thanks too.. well if activity_1 has spaces in it you will get an error <input disabled="yes" type="text" name="LWActivity1" size="20" <?php echo "value='".$row['activity_1']."'" ?>> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.