Jump to content

help on weird variable substition


jacaranda

Recommended Posts

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...

Link to comment
Share on other sites

 

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

 

Link to comment
Share on other sites

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']" ?>>

Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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']."'" ?>>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.