Jump to content

Form / Radio Button Help


jmrothermel

Recommended Posts

Ok Im sure this is probably the most basic thing - but for some reason this morning it cant come to me.  Heres the code I am using:

 

<br><br>What would you like to send:<br><table border=1 cellpadding=0 cellspacing=0><tr>";
  

     $sql = mysql_query("SELECT * FROM `pets` WHERE  user='$u'");
     while($row = mysql_fetch_array($sql)) {
      	extract($row);
      	$x=$x+1;
      	
	  
 	print "
 	<td width='20%' valign='top'>
 	<table border=0 cellpadding=2 cellspacing=0 width=100%>
 	 <Tr>
 	  <Td valign=middle align=center><input type='radio' name='id' value='$id'&img='img' value ='$img'><img src='/images/pets/$img.jpg'>$petName</td>
 	 </tr>
 	</table>
 	</td>";

	if($x%2==0) {
	 	print "</tr><Tr>";
	} 

    }

    print "</table><input type='submit' value=' Send Pet '></form>";


}

 

On this line

 

 <Td valign=middle align=center><input type='radio' name='id' value='$id'&img='img' value ='$img'><img src='/images/pets/$img.jpg'>$petName</td>

 

I want it so that when someone selects the radio button next to that image that it pulls from the database the image name and the id (the id it does but for some reason I cant get it to pull the image and post it in the form as well).  Does anyone see what I might be doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/93688-form-radio-button-help/
Share on other sites

You're either going to have to do some processing before the form is submittted with javascript (e.g. set a hidden field's value) or do the processing after the form has been submitted with php.

 

If you think about what you're doing, your trying to have two variables inside one element of the post array. Therefore, $_POST['id'] will contain the two pieces of information you require. If you use a delimiter between the information, you could explode the data and extract the relevant parts.

Archived

This topic is now archived and is closed to further replies.

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