Javascript和PHP - 将值传递给PHP查询 [英] Javascript and PHP - pass value to PHP query
问题描述
亲爱的团队,我是这个网站的新手,也是PHP :)。我需要专家的帮助,我确信我的代码不符合标准,但仍在努力。
我的代码如下所示,我在这里做的是,我从javascript获得了评估ID并将其转换为PHP变量,并且打印了所需的值。
但是当我试图将这个变量放在PHP Query中时,由于我的PHP代码不起作用,它没有传递那些值。但是,如果我传递静态值它工作正常。
Dear Team, I am new on this website and also in PHP :). I need some help from experts, and I am sure my code is not up to the mark but still working on it.
My code is as below, what I do here is, I got evaluation ID from javascript and shift it to a PHP variable and it's printing that required value as well.
but when I am trying to put this variable in PHP Query, it's not passing that values due to which my PHP code is not working. However, if I pass a static value it's working fine.
$sql = 'SELECT * FROM eval where evaid="11075"';
我想把这个$ eid传递给这个提到的查询,但是它没有用。请帮忙。
我尝试过:
I want to pass this $eid into this mentioned query but it's not working. Please help.
What I have tried:
<?php
$eid = "' + response[0].EvaluationId + '";
echo $eid;
$division = "' + response[0].Division + '";
echo $division;
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '123456';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT * FROM eval where evaid="11075"';
mysql_select_db('ops');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
if ($row['division'] == "CRM Sales - Support" AND $row['etype'] == "dddd")
{
echo "downgrade ";
}
elseif ($row['division'] == "CRM Sales - Support" AND $row['etype'] == "upre")
{
echo "update";
}
elseif ($row['division'] == "CRM Sales - Support" AND $row['etype'] == "Ponly")
{
echo "Party";
}
elseif ($row['division'] == "DME")
{
echo "devide me equal";
}
else
{
echo "Open Ended";
}
}
mysql_close($conn);
?>
推荐答案
sql ='SELECT * FROM eval其中evaid =11075';
sql = 'SELECT * FROM eval where evaid="11075"';
我想把这个
I want to pass this
eid传递给这个提到的查询,但它是不工作请帮忙。
我尝试过:
eid into this mentioned query but it's not working. Please help.
What I have tried:
<?php
eid ='+ response [0] .EvaluationId +';
echo
eid = "' + response[0].EvaluationId + '"; echo
这篇关于Javascript和PHP - 将值传递给PHP查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!