When $posting with a button click the data is not sent the first time. e.g no results are shown. if however I use the $post again the data is sent but it is the previous data. So it is always one step behind with data that is being received and blank when first trying.
So far this is what I have. P.S this is just a offline game for me to play so not a serious thing. To pass the data down:
if (this.id === me.id && this.checked) {
var str = $(this).attr('id');
var ret = str.split(" ");
var str1 = ret[0];
var str2 = ret[1]
alert(str1);
alert(str2);
if (str1) {
var variableToSend = str1;
$.post('breeding2.php', {variable: variableToSend});
}
}
breeding2.php
if (!empty($_POST['variable'])) {
$_SESSION['testfemale'] = $_POST['variable'];
$testfem2 = $_SESSION['testfemale']; //testing
$insertrecord = "INSERT INTO animal (species, gender, status,owner,past,age,birth,currentagemonths,currentageyear,purchase,type,colour,sale,minprice,maxprice,rate,cond,gestation,breedrest,timesbred,update_time,maid,mpar,feed,selling, roomid, back)
VALUES ('$animalspecies', '$randomgender', '$status', '$playersession','$playersession', 'unborn', NULL, '0', '0', NULL, '$animaltype','$pattern','$price','$price','0','0.0',NULL, NULL,NULL, NULL,NOW(),'$testfem2','$malevalue','unfed','unsold','0','$envir')";
}