Jump to content

Multiple Options for Insertation


wolfcry

Recommended Posts

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
Share on other sites

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.

Edited by wolfcry
Link to comment
Share on other sites

  • 3 weeks later...
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.