我正在尝试创建一个名为的函数saveorder.到目前为止这是我的代码:
<?php
//function foo($arg_1, $arg_2, /* ..., */ $arg_n)
function saveorder($orderid,$txnid,$date,$amount)
{
$a_str = array(
"orderid"=>"175",
"txnid"=>"RC456456456",
"date"=>"54156456465",
"amount"=>"109$"
);
$file = 'order.dat';
$contents = implode("|", $a_str);
$contents .= PHP_EOL . PHP_EOL;
file_put_contents($file, $contents);
}
echo "function will return=".saveorder($orderid);
?>
Run Code Online (Sandbox Code Playgroud)
我想我做错了因为我从未创建过自己的功能.但是,我仍想创建此功能以保存order.dat文件中的顺序.有人可以帮我创建这个功能吗?我很努力,但我无法创造它.
是否可以在Javascript函数下调用php页面?我有一个javascript函数,如果有人按OKk,我想调用php页面
到目前为止,这是我的代码
function show_confirm()
{
var r=confirm("Do You Really want to Refund money! Press ok to Continue ");
if (r==true)
{
alert("You pressed OK!");
return true;
}
else
{
alert("You pressed Cancel!");
}
}
Run Code Online (Sandbox Code Playgroud)
这个Js函数在这里使用
<td align="center"><input name="Refund" onclick="show_confirm()" type="submit" value="Refund" /></td>
Run Code Online (Sandbox Code Playgroud)
现在我想如果用户按确定然后call other php page...
mysql_fetch_array在我的代码中不起作用: - 我得到了这样的错误......
警告:mysql_fetch_array():提供的参数不是第38行的C:\ Program Files\xampp\htdocs\finalreports\generatereport.php中的有效MySQL结果资源
我的代码到目前为止....
if(array_key_exists('server_guid',$_GET))
{
$guids = $_GET['server_guid'];
$guid_array = explode(",",$guids);
//$reporttype = "Server Resources";
for($i=0 ; $i<count($guid_array); $i++)
{
$query = "select vid from vendor_registration where bussname='".$guid_array[$i]."'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$name_array[$i] = $row[0];
}
}
}
Run Code Online (Sandbox Code Playgroud)