1

Hi i am trying to assign the php variable value to the radio button's value

Here is what i am doing. But i am not able to see any value when i am alerting the value through java-script.

code:

  echo "<td class='ad'>" . $row['address'] . "</td>";
  echo "<td>"; 
  echo '<input type="radio" name="address" value='$row['address']'/>';

i want to assign the $row['address'] value to input value=

how can i do this?

1
  • echo '<input type="radio" name="address" value=' . $row['address']' . '/>'; Commented Aug 20, 2013 at 8:26

3 Answers 3

1

You got it right in the 1st line, while the 3rd should be like this:

echo '<input type="radio" name="address" value="' . $row['address'] . '"/>';

see http://php.net/manual/en/language.operators.string.php

Sign up to request clarification or add additional context in comments.

Comments

1

If you're not using the in-php echo (you're out of php code), you can write this:

< input name="address" type="radio" value="< ?= $row['address']; ? > Hope to be useful. I added some spaces to make my answer ok

Comments

0

you will need to use . which is the string concatenation operator in php. what you have done is almost correct but you have not concatenated the string value with the php variable properly.

echo '<input type="radio" name="address" value=' . $row['address'] . '/>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.