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

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.