Hi i want to get values from PHP files and make them usuable like array. I'm using jquery. How should i format retriever and php file to retrieve them all.
PHP dosyası: i anda 1 almak için anahtarı kullanılır ama bu yöntem berbat
<?php
ob_start();
session_start();
include('mysql_config.php');
$konto = $_SESSION['login'];
$temp=mysql_fetch_array(mysql_query("SELECT `curchar` FROM `users` WHERE `login`='$konto'"));
$id = $temp['curchar'];
$gracz=mysql_fetch_array(mysql_query("SELECT * FROM `chars` WHERE `id`='$id'"));
$gracz['max_pz']=94+($gracz['str']+$gracz['stm']*5);
$gracz['max_pe']=7.1-($gracz['str']*0.1)+$gracz['stm']+$gracz['int']*2;
$gracz['max_exp']=($gracz['lvl']*10)*25;
if ($gracz['max_exp'] <= $gracz['exp'])
{
$gracz['lvl']++;
$zostalo = $gracz['exp']-$gracz['max_exp'];
mysql_query("UPDATE `chars` SET lvl=lvl+1, stats=stats+3, exp='$zostalo' WHERE `id`='$id'");
$gracz['exp']=$zostalo;
$gracz['max_exp']=($gracz['lvl']*10)*25;
}
$lol=$_POST['name'];
switch ($lol) {
case 'pz':
echo $gracz['pz'];
break;
case 'max_pz':
echo $gracz['max_pz'];
break;
case 'pe':
echo $gracz['pe'];
break;
case 'max_pe':
echo $gracz['max_pe'];
break;
case 'max_exp':
echo $gracz['max_exp'];
break;
case 'str':
echo $gracz['str'];
break;
case 'dex':
echo $gracz['dex'];
break;
case 'int':
echo $gracz['int'];
break;
case 'stm':
echo $gracz['stm'];
break;
case 'stats':
echo $gracz['stats'];
break;
case 'exp':
echo $gracz['exp'];
break;
case 'lvl':
echo $gracz['lvl'];
break;
case 'mapa':
echo $gracz['mapa'];
break;
case 'x':
echo $gracz['x'];
break;
case 'y':
echo $gracz['y'];
break;
default:
echo "post jest pusty";
break;
}
ob_end_flush();
?>
JS dosyası (alıcısı): Burada 1 değişkeni almak retriever var ama neden tarayıcı ben bunu istemiyorum kalıyor ki eşitleme kullanıyor
function get_char_val(merk)
{
var returnValue = null;
$.ajax({
type: "POST",
async: false,
url: "char_info2.php",
data: { name: merk },
dataType: "html",
success: function(data)
{
returnValue = data;
}
});
return returnValue;
}