我在PHP上进行了此查询,该查询必须根据不同的值进行更改。
我需要在html页面上输入这些变量,我将其中一个值命名为shiftdate,但可能我将不得不通过json在查询中放置更多变量。
问题是我的查询没有读取var
我现在有这个权利
<?php
function getArraySQL(){
$dsn = "prueba";
$connect = odbc_connect( $dsn, '', '' );
$shiftdate = $_GET["shiftdate"]; //one of the variables that i need to input on my query
$query = " SELECT hist_statusevents.reason, Sum(hist_statusevents.duration/3600) AS 'Duracion'
FROM hist_statusevents, hist_eqmtlist, hist_exproot
WHERE hist_exproot.shiftindex = hist_statusevents.shiftindex AND hist_exproot.ddmmyy =$shiftdate
GROUP BY hist_statusevents.reason
ORDER BY Duracion DESC";
if(!$rs = odbc_exec($connect, $query)) die();
$rawdata = array();
$i=0;
while($row = odbc_fetch_array($rs))
{
$rawdata[$i] = $row;
$i++;
}
odbc_close( $connect );
return $rawdata;
}
$myarray = getArraySQL();
echo json_encode($myarray);
我要进入查询的值在此html部分中:
<section class="post col-md-12">
<input type="text" placeholder="Date on dd-mm-yy" id="shiftdate">
</section>
通过此json(退出,{shiftdate:“ shiftdate”},效果很好),但是如果我添加它,它将不起作用:
$ {document).ready(function(){
$ .getJSON('dbquery_plus_shiftdate.php',{shiftdate:“ shiftdate”},function(data){
$ .each(data,function(key,val){
$('ul')。append(''+ val.reason +'-'+ val.Duracion +'');
});
});
});
另一方面,
$ shiftdate = $ _GET [“ shiftdate”]; //我需要在查询中输入的变量之一
PHP页面给我这个错误:
注意:未定义的索引:第5行的C:\ xampp \ htdocs \ byp1 \ dbquery_plus_shiftdate.php中的shiftdate
警告:odbc_exec():SQL错误:[Microsoft] [SQL Server Native Client 10.0] [SQL Server]直接执行SQL;第12行上的C:\ xampp \ htdocs \ byp1 \ dbquery_plus_shiftdate.php中没有SQLExecDirect中的SQL状态01000
javascript参考方案
您想实现什么,因为我不明白您的问题。
您想用来自查询的数据来填充html,或者想通过输入的数据来获取Json。
例如,如果您具有以下JSON对象(删除python的分号):values = { a: 1, b: { c: 2, d: { e: 3 } }, f: 4, g: 5 }; 如果您尝试在JS中打印values,它将正常工作。但是在Python中,它将返回错误NameError: name 'a' is not defined,这意味着未定…
Mongo汇总 - javascript我的收藏中有以下文件{ "_id": ObjectId("54490b8104f7142f22ecc97f"), "title": "Sample1", "slug": "samplenews", "cat": …
验证php中的javascript对象 - php在我的用户界面中,用户可以构建一些javascript对象,例如:var box = { "width": "100px", "height": "200px", "click": function () { alert("You clicked t…
如何从客户端将数据插入数据库? - javascript我是Web开发的初学者,可以访问cpanel上托管的网站,并且需要对其进行一些更改。这个网站的后端是由蛋糕PHP制作的,我想使用ajax从客户端将一些数据插入其数据库。问题是我不知道如何获取负责插入数据库的PHP文件的URL。参见下面的代码:var xhttp = newXMLHttpRequest(); xhttp.onreadystatechange= …
执行onclick时获得意外令牌 - javascript我正在使用onclick事件从PHP调用JS函数。这是我的代码:我在一个函数中,因此我需要通过PHP来完成它,因为然后我会返回:$html = '<input type="checkbox" checked value="1" id="setGetSku" name="se…