1 Replies - 506 Views - Last Post: 17 May 2015 - 02:05 AM

#1 nooreo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 06-May 15

How to pass information to a php function

Posted 16 May 2015 - 08:34 PM

Hello,

I am trying to do a calculation.

In html this is my script to take the data to the php class

function estimatedbill() {
   
		
		var objJSON = {
						seconds: seconds,
				
						}
								
			$.post('calculations.php', objJSON ).error(function() {
					  console.log("this is the calculations part and it didn''t send it to calculations.php");
			}).success(function(data) {
				
				  	console.log("data gathered"); 
				//here output the result back 
				 $("p").text(data);

				 	console.log(seconds); 
			
			

			});
}



But in the php, i was thinking to make a class with different functions and pass the seconds value along to do different calculations with it. SO far I have this (below) but im not sure what to do next bcause when i place the echo inside the function i get this whole papragraph error. If you could just guide me on hwo to start i'd appreciate it :)/>


<?php 

$seconds=$_POST["seconds"]; 


echo "it echoed ". $seconds;

function billestimation($seconds){


}

?> 



Is This A Good Question/Topic? 0
  • +

Replies To: How to pass information to a php function

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4303
  • View blog
  • Posts: 13,677
  • Joined: 08-June 10

Re: How to pass information to a php function

Posted 17 May 2015 - 02:05 AM

put your calculation code into the function, call the function with the received data, echo the processed data. that is all that’s needed from the PHP side.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1