下面是来电弹屏以后,从数据库中查询一个客户的代码实现。查到一个客户时,显示这个客户。未查到时,添加一个客户。
<?php
session_start();
$ext1 = $_SESSION['userext'];
$num = $_GET['num'];
require_once("config.inc.php");
$num = $_GET['tel'];
$num = trim($num);
mysql_connect($dbconfig['db_server'],$dbconfig['db_username'],$dbconfig['db_password']) or die("ERR");
$conn = mysql_select_db($dbconfig['db_name']);
echo $sql = "select * from vtiger_account where phone = '{$num}' limit 1 ";
$rs = mysql_query($sql);
var_dump($rs);
$aid = "";
if($r = mysql_fetch_array($rs))
{
$aid = $r['accountid'];
header("Location: index.php?module=Accounts&view=Detail&record={$aid}");
}
else
{
header("Location: index.php?module=Accounts&view=Edit&newnu={$num}");
}
?>