jmrothermel Posted February 29, 2008 Share Posted February 29, 2008 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? Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 29, 2008 Share Posted February 29, 2008 Not sure I understand you correctly but do you realise you have value set twice in your input field? value='$id'&img='img' value ='$img' Quote Link to comment Share on other sites More sharing options...
jmrothermel Posted February 29, 2008 Author Share Posted February 29, 2008 Ah, that would be why then. DUH. So if I want to set two values so that it inputs two pieces of information into the form and into the action that follows what code would I use? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted February 29, 2008 Share Posted February 29, 2008 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. Quote Link to comment Share on other sites More sharing options...
jmrothermel Posted February 29, 2008 Author Share Posted February 29, 2008 Ahhhh that worked perfectly GingerRobot! For some reason it just didnt come to me on my own this morning. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.