$clientname=$_POST['clientname'];
$techname=$_POST['techname'];
$currentstatus=$_POST['currentstatus'];
$time1=$_POST['time1'];
$time2=$_POST['time2'];
$recordcontent=$_POST['recordcontent'];
$topbandwidth=$_POST['topbandwidth'];
$initialstatus=$_POST['initialstatus'];
$createddate=$_POST['createddate'];echo $recordcontent;
echo $topbandwidth;
echo $initialstatus;
echo $createddate;//echo "$techname";
//echo "$currentstatus";
//echo $time1;
//echo $time2;
if($recordcontent!='')
{
$x="任务信息跟进记录";
echo $x;
}
else{$x==''; $rsc==''; $recordcontent=='';}
if($topbandwidth!='')
{
$y="任务带宽峰值记录";
echo $y;
}
else{$y==''; $rsd==''; $topbandwidth=='';}
if($createddate!='')
{
$sqla=mysql_query("select ".$createddate." from task where clientname='$clientname' and techname='$techname'");    $z="任务初始记录日期";
echo $z;
    }
else{$z==''; $rsa==''; $createddate=='';}
if($initialstatus!='')
{
$sqlb=mysql_query("select ".$initialstatus." from task where clientname='$clientname' and techname='$techname'");
    
$w="任务初始状态记录";
echo $w;
}
else{$w==''; $rsb==''; $initialstatus=='';}
/////////time condition 1, both null
if ($time1=='' && $time2=='')
{if ($clientname!='all' && $techname!='all' && $currentstatus!='all')
///////////////////////where A,B,C
    {
$sql1 = mysql_query("select clientname,techname,currentstatus,recorddate from jobrecord where clientname = '$clientname' and techname = '$techname' and currentstatus = '$currentstatus'");$sqlc = mysql_query("select ".$recordcontent." from jobrecord where clientname = '$clientname' and techname = '$techname' and currentstatus = '$currentstatus'");
$sqld = mysql_query("select ".$topbandwidth." from jobrecord where clientname = '$clientname' and techname = '$techname' and currentstatus = '$currentstatus'");
echo"<center><table><tr><td>客户名称</td><td>技术负责人</td><td>任务历史状态记录</td><td>$w</td><td>任务历史记录日期</td><td>$z</td><td>$x</td><td>$y</td></tr>";while ($rs1=mysql_fetch_object($sql1) && $rsa=mysql_fetch_object($sqla) && $rsb=mysql_fetch_object($sqlb) && $rsc=mysql_fetch_object($sqlc) && $rsd=mysql_fetch_object($sqld))
{
 echo '<tr><td>'.$rs1->clientname.'</td><td>'.$rs1->techname.'</td><td>'.$rs1->currentstatus.'</td><td>'.$rsb->initialstatus.'</td><td>'.$rs1->recorddate.'</td><td>'.$rsa->createddate.'</td><td>'.$rsc->recordcontent.'</td><td>'.$rsd->topbandwidth.'</td></tr>'; }
 echo'</table></center>';报错:Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

解决方案 »

  1.   

    //1.没看到你用mysql_connect()连接数据库;
    //2.执行SQL语句时,都加上错误输出,比如:
    $sql1 = mysql_query("select clientname,techname,currentstatus,recorddate from jobrecord where clientname = '$clientname' and techname = '$techname' and currentstatus = '$currentstatus'") OR die(mysql_error());
      

  2.   

    你好,1.数据库连接我没有帖,没有问题;2.or die('sql die')没有写,因为想看到报错行信息,另外SQL在后台运行没有问题,我找不到原因,在WHILE的时候SQL结果有问题,很奇怪,请再帮帮忙,感谢!!! 
      

  3.   

    $sqla 和 $sqlb 是有条件产生的,你怎么不检查是否有效就是用呢?if($createddate!='')
    {
    $sqla=mysql_query("select ".$createddate." from task where clientname='$clientname' and techname='$techname'");if($initialstatus!='')
    {
    $sqlb=mysql_query("select ".$initialstatus." from task where clientname='$clientname' and techname='$techname'");
        
      

  4.   

    你好,这个是我后修改的,之前写在了if 的外面,如果是空值,也是调用$sqla,$sqlb 的,只是变量的值==‘’,测试也是报的错。
      

  5.   

    在 
    while ($rs1=mysql_fetch_object($sql1) && $rsa=mysql_fetch_object($sqla) && $rsb=mysql_fetch_object($sqlb) && $rsc=mysql_fetch_object($sqlc) && $rsd=mysql_fetch_object($sqld))
    之前加入:
    echo "sql1:$sql1<br />sqla:$sqla<br />sqlb:$sqlb<br />sqlc:$sqlc<br />sqld:$sqld";
    看一下都是些什么 或帖出结果
      

  6.   

    你好, 运行结果:
    sql1:Resource id #5
    sqla:Resource id #4
    sqlb:
    sqlc:Resource id #6
    sqld:
      

  7.   

     sqlb 和 sqld 有问题
      

  8.   

    recordcontenttopbandwidthinitialstatuscreateddate任务信息跟进记录任务带宽峰值记录任务初始记录日期任务初始状态记录
    客户名称 技术负责人 任务历史状态记录 任务初始状态记录 任务历史记录日期 任务初始记录日期 任务信息跟进记录 任务带宽峰值记录 
    sql1:Resource id #6
    sqla:Resource id #4
    sqlb:Resource id #5
    sqlc:Resource id #7
    sqld:Resource id #8 
    勾选了4个check box 后得出的结果,同时echo了变量的值
      

  9.   

    你好,是的,我尝试过先取array,然后再fetch_object,同样数据插不进显示结果的表