0

Is there a way to assign 2 variable values to a value in a form:

echo "  <input name='Radio1' type='radio' value='$course_id . $date_1'/>$date_1</br>";
3
  • 2
    What are you trying to achieve? Commented May 11, 2012 at 9:22
  • 1
    You can concatenate them using a "_" or other symbol. Can you explain what are you trying to achieve? Commented May 11, 2012 at 9:22
  • My apologies, I stated the question badly, I'm getting a result but it has the . in between, I tried STEFAN's answer and got the result I wanted. Commented May 11, 2012 at 9:26

4 Answers 4

2

This would be what you are looking for:

echo "  <input name='Radio1' type='radio' value='$course_id$date_1'/>$date_1</br>";

Or in a more readable way:

echo "  <input name='Radio1' type='radio' value='".$course_id.$date_1."'/>$date_1</br>";

Regards,

STEFAN

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

2 Comments

More readable would be <input name="Radio1" type="radio" value="<?php echo $course_id, $date_1 ?>" /><?php echo $date_1 ?></br>... well, that might be subjective...
it definitely is, I am not a big fan of PHPs template like usage
2

You could do this:

echo '<input type="radio" name="Radio1" value="',$course_id,'_',$date_1,'" />',$date_1,'<br />';

On the receiving page:

$parts = explode('_',$_GET['Radio1']);
$course_id = $parts[0];
$date = $parts[1];

Comments

1

This way has the data separated in perhaps a more useful way:

<input type="text" name="course[$course_id]" value="$date_1" />

Comments

0

you can use printf

$input = "<input name='Radio1' type='radio' value='%s%s'/>%s</br>";
printf ( $input, $course_id, $date_1, $date_1 );

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.