wolfcry Posted April 7, 2013 Share Posted April 7, 2013 Hello all, I'm not really sure if this should be in the SQL portion or not. I don't think so because I'm not having issues with SQL syntax, just the proper PHP (?) coding to achieve a specific result. What I'm trying to do have the user perform a randomized calculation that outputs multiple results; displaying those results on the screen and have them select the result they wish to keep. This result is then inserted into the database accordingly. To give a better example, let's say the user performs the action and the following results are displayed (I'm using names just as an example): David Josh Carrie Spike and they wish to keep "Spike". When they click on the link that states, "Save", Spike is then inserted into the database. I can get the multiple calculations to perform; have them show up on the page with the "save" link next to each one, but nothing is inserted when the link is clicked. Can PHP perform this action or will I need to use JavaScript for this? Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/ Share on other sites More sharing options...
Jessica Posted April 7, 2013 Share Posted April 7, 2013 Code? Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/#findComment-1423431 Share on other sites More sharing options...
wolfcry Posted April 10, 2013 Author Share Posted April 10, 2013 Sorry Jessica, I was trying to get multiple things done at once and completely spaced it. My apologies. Here is the tidbit of code. Obviously there's more before and after but none of that pertains to this portion. { echo '<table><tr><td>'; for($i=1; $i<=$Sets; $i++){ $Calcs = CalcType($SpecId, $min, $CQuantity, $CType); echo 'Calculations for '.$SetText[$i]; foreach ($Calcs as $key => $DisplayCalcs) { $SetCalcs[] = $DisplayCalcs; echo $DisplayCalcs.', '; } if($Sets == 1){ $SetResults = implode(',',$Calcs); DB_Insert($EData,$Total,$Modified,$Counter,$Sets,$SetResults,$TimeStamp); }else if($Sets >= 2){ echo '</td><td> => <input type="button" name="SelectThis" value="Keep This Set"></td><tr><td>'; } } echo '</td></tr></table>'; if(isset($_POST['SelectThis'])){ DB_Insert($EData,$Total,$Modified,$Counter,$Sets,$SetResults,$TimeStamp); } } As previously stated, everything works up to the point of trying to select a specific calculation from multiple options. I'm sure I'm just spacing something and I'll most likely need an OnClick JS handler for this, which is fine, but I was really hoping I could do it strictly using PHP. I'm sure it's due to the fact that I'm not using <form> tags with the buttons and redirecting back to the page, but I was hoping there was a way to do it without needing to use them. Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/#findComment-1423872 Share on other sites More sharing options...
wolfcry Posted April 12, 2013 Author Share Posted April 12, 2013 This can only be done with JS/Ajax correct? Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/#findComment-1424358 Share on other sites More sharing options...
wolfcry Posted May 1, 2013 Author Share Posted May 1, 2013 Anybody out there? lol Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/#findComment-1427500 Share on other sites More sharing options...
Jessica Posted May 1, 2013 Share Posted May 1, 2013 On 4/12/2013 at 2:26 PM, wolfcry said: This can only be done with JS/Ajax correct? If you don't want to reload the whole page, yes. Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/#findComment-1427503 Share on other sites More sharing options...
mac_gyver Posted May 1, 2013 Share Posted May 1, 2013 a form field of any kind won't do anything unless it is inside a form tag or you use a js event with it. why not just use a <a href=''></a> link with a css button or an image for the button? Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/#findComment-1427504 Share on other sites More sharing options...
wolfcry Posted May 2, 2013 Author Share Posted May 2, 2013 Thanks for the answers all. I figured as much lol. @mac_gyver: I would but in the end I would still have to redirect or reload which is what I was trying to stay away from. Link to comment https://forums.phpfreaks.com/topic/276661-multiple-options-for-insertation/#findComment-1427776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.